# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77244 | 2018-09-24T09:38:01 Z | farukkastamonuda | Dynamite (POI11_dyn) | C++14 | 1849 ms | 27196 KB |
#include <bits/stdc++.h> #define li 300005 #define mid (bas+son)/2 using namespace std; int n,m,ans,A[li],x,y,say; vector<int> vv[li]; int solve(int node,int ata,int sayi){ int t=0,v=0; for(int i=0;i<(int)vv[node].size();i++){ int go=vv[node][i]; if(ata==go) continue; int u=solve(go,node,sayi); if(u==0) continue; if(u>0) v=max(v,u); else t=min(t,u); } if(abs(t)>=sayi){ ans++; return sayi; } if(t==0 && v==0) return A[node]; if(v>abs(t)) return v-1; return t-1; } int can(int k){ ans=0; if(solve(1,0,k)<0) ans++; if(ans<=m) return 1; return 0; } int main(){ scanf("%d %d",&n,&m); for(int i=1;i<=n;i++) {scanf("%d",&A[i]);say+=A[i];} for(int i=1;i<n;i++){ scanf("%d %d",&x,&y); vv[x].push_back(y); vv[y].push_back(x); } if(say<=m){ printf("0\n"); return 0; } int bas=1,son=n-1; while(bas<=son){ if(can(mid)==1) son=mid-1; else bas=mid+1; } printf("%d\n",bas); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7416 KB | Output is correct |
2 | Correct | 8 ms | 7520 KB | Output is correct |
3 | Correct | 8 ms | 7520 KB | Output is correct |
4 | Incorrect | 8 ms | 7520 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 7584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 7584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 7584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 17 ms | 7924 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 62 ms | 9588 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 127 ms | 11328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 671 ms | 14964 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1849 ms | 20864 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1575 ms | 27196 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |