제출 #345611

#제출 시각아이디문제언어결과실행 시간메모리
345611izhang05Traffic (IOI10_traffic)C++17
50 / 100
431 ms84716 KiB
#ifndef DEBUG #include <traffic.h> #endif #include <bits/stdc++.h> using namespace std; const int maxn = 1e6; vector<int> adj[maxn]; int LocateCentre(int n, int p[], int s[], int d[]) { int left = 0, right = 0; for (int i = 0; i < n - 1; ++i) { adj[s[i]].push_back(d[i]); adj[d[i]].push_back(s[i]); } for (int i = 0; i < n; ++i) { right += p[i]; } pair<int, int> sol = {1e9, 0}; for (int i = 0; i < n; ++i) { right -= p[i]; sol = min(sol, make_pair(max(left, right), i)); left += p[i]; } return sol.second; } #ifdef DEBUG int main() { int n = 5, p[5]{3, 5, 8, 10, 9}, s[4]{0, 1, 2, 3}, d[4]{1, 2, 3, 4}; cout << LocateCentre(n, p, s, d) << "\n"; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...