제출 #197039

#제출 시각아이디문제언어결과실행 시간메모리
197039mario05092929Fireworks (APIO16_fireworks)C++11
100 / 100
284 ms47400 KiB
#if 1 #include <bits/stdc++.h> using namespace std; int n,m,p[300005],c[300005],sz[300005]; long long s[300005],l,r; priority_queue <long long> *q[300005]; int main() { scanf("%d %d", &n, &m); for(int i = 2;i <= n+m;i++) { scanf("%d %d", &p[i], &c[i]); } for(int i = n+1;i <= n+m;i++) { q[i] = new priority_queue<long long>(2,0); } for(int i = n+m;i >= 1;i--) { while(sz[i]--) q[i] -> pop(); r = q[i] -> top(); q[i] -> pop(); l = q[i] -> top(); q[i] -> pop(); q[i] -> push(l+c[i]); q[i] -> push(r+c[i]); s[p[i]] += s[i]+c[i]; if(!q[p[i]]) { q[p[i]] = q[i]; continue; } if(q[p[i]] -> size() < q[i] -> size()) swap(q[p[i]],q[i]); while(!q[i] -> empty()) { q[p[i]] -> push(q[i] -> top()); q[i] -> pop(); } sz[p[i]]++; } q[0] -> pop(); while(!q[0] -> empty()) { s[0] -= q[0] -> top(); q[0] -> pop(); } printf("%lld",s[0]); return 0; } #endif // 1

컴파일 시 표준 에러 (stderr) 메시지

fireworks.cpp: In function 'int main()':
fireworks.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
fireworks.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &p[i], &c[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...