(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #199322

#제출 시각아이디문제언어결과실행 시간메모리
199322mythosTraffic (IOI10_traffic)C++14
100 / 100
1905 ms166904 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[1000100]; int n, opt, a[1000100]; long long res = 1e18, sum = 0; long long cal(int x, int pa) { long long mv = 0, s = 0; for (int i = 0; i < (int) adj[x].size(); i++) { if (adj[x][i] == pa) continue; long long t = cal(adj[x][i], x); s += t; mv = max(mv, t); } s += a[x]; mv = max(mv, sum - s); if (res > mv) { res = mv; opt = x; } return s; } int LocateCentre(int N, int pp[], int S[], int D[]) { n = N; for (int i = 0; i < n; i++) { a[i] = pp[i]; sum += a[i]; } for (int i = 0; i < n - 1; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } cal(0, -1); return opt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...