結果
問題 | No.2999 Long Long Friedrice |
ユーザー |
![]() |
提出日時 | 2024-12-24 10:34:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 2,341 ms |
コンパイル使用メモリ | 203,812 KB |
最終ジャッジ日時 | 2025-02-26 16:22:29 |
ジャッジサーバーID (参考情報) |
judge1 / 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;}