結果

問題 No.3434 [Cherry 8th Tune N] 大きくして Hold on Card!
コンテスト
ユーザー SnowBeenDiding
提出日時 2026-01-23 21:31:52
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,213 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,834 ms
コンパイル使用メモリ 429,476 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2026-01-23 21:32:24
合計ジャッジ時間 24,696 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#include <atcoder/all>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;

typedef long long ll;

template <typename T, typename S>
bool chmax(T &a, S b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    vector<pair<int, int>> v(n);
    rep(i, 0, n) {
        cin >> a[i];
        v[i] = {a[i], i};
    }
    rep(i, 0, n) cin >> b[i];
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    vector<ll> as(n + 1), bs(n + 1);
    rep(i, 0, n) {
        as[i + 1] = v[i].first + as[i];
        bs[i + 1] = b[i] + bs[i];
    }
    reverse(as.begin(), as.end());
    ll mx = as[0], cnt = 0;
    rep(i, 1, n + 1) if (chmax(mx, as[i] + bs[i])) cnt = i;
    string ans(n, '0');
    reverse(v.begin(), v.end());
    rep(i, 0, cnt) ans[v[i].second] = '1';
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int t;
    cin >> t;
    while (t--) solve();
}
0