結果

問題 No.3434 [Cherry 8th Tune N] 大きくして Hold on Card!
コンテスト
ユーザー a01sa01to
提出日時 2026-01-25 00:21:55
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 866 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,349 ms
コンパイル使用メモリ 345,376 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2026-01-25 00:22:14
合計ジャッジ時間 18,885 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    sort(p.begin(), p.end(), [&](int i, int j) {
      return a[i] < a[j];
    });
    vector<ll> suma(n + 1, 0), sumb(n + 1, 0);
    rep(i, n) suma[i + 1] = suma[i] + a[p[i]], sumb[i + 1] = sumb[i] + b[i];
    pair<ll, int> ans = { -1e18, -1 };
    rep(i, n + 1) {
      ll val = suma[n] - suma[i] + sumb[i];
      if (ans.first < val) ans = { val, i };
    }
    string s(n, '0');
    rep(i, ans.second) s[p[i]] = '1';
    cout << s << '\n';
  }
  return 0;
}
0