結果
問題 | No.2999 Long Long Friedrice |
ユーザー |
![]() |
提出日時 | 2024-12-24 10:34:14 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 4,217 ms |
コンパイル使用メモリ | 210,192 KB |
実行使用メモリ | 26,916 KB |
最終ジャッジ日時 | 2024-12-24 10:34:21 |
合計ジャッジ時間 | 5,802 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;void fast_io() {ios::sync_with_stdio(false);std::cin.tie(nullptr);}int main() {fast_io();int n;cin >> n;vector<int> a(n), b(n);for (int i = 0; i < n; i++) {cin >> a[i];}const int M = 1e6 + 1;vector<vector<int>> g(M);for (int i = 0; i < n; i++) {cin >> b[i];g[a[i]].push_back(a[i] + b[i]);}int ans = 1;deque<int> dq{1};vector<bool> vis(M);vis[1] = true;while (!dq.empty()) {int u = dq.front();dq.pop_front();ans = max(ans, u);for (int v : g[u]) {if (vis[v]) {continue;}dq.push_back(v);vis[v] = true;}}cout << ans << endl;}