結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
using maxt = atcoder::modint1000000007;

int ans = 0;
vector<vector<int>> To(1000001, vector<int>(0, 0));
vector<bool> seen(1000001, false);
void dfs(int v) {
	ans = max(ans, v);
	seen.at(v) = true;
	for(int next_v : To.at(v)) {
		if(seen.at(next_v)) {
			continue;
		}
		dfs(next_v);
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(int &o : A) {
		cin >> o;
	}
	vector<int> B(N);
	for(int &o : B) {
		cin >> o;
	}
	for(int i = 0; i < N; i++) {
		To.at(A.at(i)).push_back(A.at(i) + B.at(i));
	}
	dfs(1);
	cout << ans << endl;
}
0