結果

問題 No.2999 Long Long Friedrice
ユーザー ooaiu
提出日時 2024-12-24 16:04:16
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 3,683 ms
コンパイル使用メモリ 250,572 KB
実行使用メモリ 50,560 KB
最終ジャッジ日時 2024-12-24 16:04:23
合計ジャッジ時間 5,788 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for(auto&x: A) cin >> x;
    for(auto&x: B) cin >> x;
    constexpr int M = 2e6;
    vector<vector<int>> G(M);
    for(int i = 0; i < N; i++)
    {
        G[A[i]].push_back(A[i] + B[i]);
    }
    vector<bool> ans(M);
    int res = 1;
    ans[1] = 1;
    for(int i = 1; i < M; i++) if(ans[i]) {
        for(int nv: G[i]) 
        {
            ans[nv] = 1;
            res = max(res, nv);
        }
    }
    cout << res << endl;
}
0