# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
198649 | 2020-01-27T07:51:14 Z | arnold518 | Magic Tree (CEOI19_magictree) | C++14 | 184 ms | 36984 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, MM, K, D[MAXN+10], W[MAXN+10]; vector<int> adj[MAXN+10]; map<int, ll> M[MAXN+10]; void dfs(int now) { for(int nxt : adj[now]) { dfs(nxt); if(M[now].size()<M[nxt].size()) swap(M[now], M[nxt]); for(auto it : M[nxt]) M[now][it.first]+=it.second; } if(D[now]) { vector<map<int, ll>::iterator> V; ll s=0; auto it=M[now].upper_bound(D[now]); for(; it!=M[now].end(); it++) { s+=it->second; if(W[now]<s) break; V.push_back(it); } if(it!=M[now].end()) it->second-=W[now]; for(auto jt : V) M[now].erase(jt); M[now][D[now]]+=W[now]; } } int main() { int i, j; scanf("%d%d%d", &N, &MM, &K); for(i=2; i<=N; i++) { int u; scanf("%d", &u); adj[u].push_back(i); } for(i=1; i<=MM; i++) { int v, d, w; scanf("%d%d%d", &v, &d, &w); D[v]=d; W[v]=w; } dfs(1); ll ans=0; for(auto it : M[1]) ans+=it.second; printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 7420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 18424 KB | Output is correct |
2 | Correct | 70 ms | 19832 KB | Output is correct |
3 | Correct | 184 ms | 36984 KB | Output is correct |
4 | Correct | 135 ms | 20080 KB | Output is correct |
5 | Correct | 178 ms | 22008 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 7544 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 117 ms | 15584 KB | Output is correct |
2 | Correct | 113 ms | 14840 KB | Output is correct |
3 | Correct | 96 ms | 19576 KB | Output is correct |
4 | Correct | 71 ms | 15980 KB | Output is correct |
5 | Correct | 78 ms | 27512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 7420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 8184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 7420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 7420 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |