# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
362278 |
2021-02-02T14:02:59 Z |
saifu |
Traffic (IOI10_traffic) |
C++14 |
|
0 ms |
0 KB |
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define int long long
#define endl "\n"
#define mod 1000000007
#define inf (int)1e18
const int mxn = 1e6+10;
vector<int> g[mxn];
int people[mxn];
int dp[mxn];
void dfs(int v, int p=-1){
dp[v] = people[v];
for(int u : g[v]){
if(u==p) continue;
dfs(u,v);
dp[v] += dp[u];
}
}
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int i=0;i<n;i++) cin >> people[i];
for(int i=0;i<n-1;i++){
int u,v; cin >> u >> v;
g[v].push_back(u);
g[u].push_back(v);
}
int mn = inf;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++) dp[i] = 0;
dfs(i);
int mx = 0;
for(int u : g[i]){
mx = max(mx,dp[u]);
}
mn = min(mn,mx);
}
cout << mn << endl;
return 0;
}
Compilation message
/tmp/ccpbhB62.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccc5ASoK.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/ccpbhB62.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status