結果
問題 |
No.2999 Long Long Friedrice
|
ユーザー |
![]() |
提出日時 | 2024-12-24 10:33:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 2,416 ms |
コンパイル使用メモリ | 204,464 KB |
最終ジャッジ日時 | 2025-02-26 16:22:17 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 -- * 3 |
other | AC * 5 MLE * 1 -- * 27 |
ソースコード
#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]) { dq.push_back(v); vis[v] = true; } } cout << ans << endl; }