結果

問題 No.2999 Long Long Friedrice
ユーザー 遭難者
提出日時 2024-12-20 13:07:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,185 bytes
コンパイル時間 4,394 ms
コンパイル使用メモリ 254,396 KB
最終ジャッジ日時 2025-02-26 15:49:47
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 -- * 3
other AC * 5 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using mint = atcoder::modint998244353;
using maxt = atcoder::modint1000000007;
vector<ll> Era(int N) {
  vector<ll> ans(0, 0);
  vector<bool> isprime(N + 1, true);
  isprime.at(1) = false;
  for(int i = 1; i <= N; i++) {
    if(isprime.at(i)) {
      ans.push_back(i);
      for(int j = 2 * i; j <= N; j += i) {
        isprime.at(j) = false;
      }
    }
  }
  return ans;
}
ll POW(ll a, int N) {
  if(N == 1) {
    return a;
  }
  ll ans = POW(a, N / 2) * POW(a, N / 2);
  if(N % 2 == 1) {
    ans *= a;
  }
  return ans;
}
//ライブラリここまで

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