結果
問題 | No.2999 Long Long Friedrice |
ユーザー |
![]() |
提出日時 | 2024-12-24 10:33:44 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 620 bytes |
コンパイル時間 | 2,670 ms |
コンパイル使用メモリ | 210,376 KB |
実行使用メモリ | 844,664 KB |
最終ジャッジ日時 | 2024-12-24 10:33:59 |
合計ジャッジ時間 | 13,699 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 MLE * 1 |
other | AC * 30 TLE * 2 MLE * 1 |
ソースコード
#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;}