답안 #197039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197039 2020-01-18T09:18:42 Z mario05092929 Fireworks (APIO16_fireworks) C++11
100 / 100
284 ms 47400 KB
#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

Compilation message

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]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 400 KB Output is correct
8 Correct 2 ms 396 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 296 KB Output is correct
14 Correct 2 ms 360 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 400 KB Output is correct
18 Correct 2 ms 396 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 360 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 2 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 544 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 3 ms 504 KB Output is correct
36 Correct 4 ms 764 KB Output is correct
37 Correct 9 ms 760 KB Output is correct
38 Correct 5 ms 760 KB Output is correct
39 Correct 5 ms 632 KB Output is correct
40 Correct 4 ms 504 KB Output is correct
41 Correct 4 ms 632 KB Output is correct
42 Correct 4 ms 632 KB Output is correct
43 Correct 5 ms 760 KB Output is correct
44 Correct 5 ms 888 KB Output is correct
45 Correct 5 ms 888 KB Output is correct
46 Correct 7 ms 1144 KB Output is correct
47 Correct 5 ms 1176 KB Output is correct
48 Correct 7 ms 1016 KB Output is correct
49 Correct 6 ms 1016 KB Output is correct
50 Correct 5 ms 888 KB Output is correct
51 Correct 5 ms 888 KB Output is correct
52 Correct 6 ms 1016 KB Output is correct
53 Correct 6 ms 1016 KB Output is correct
54 Correct 6 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 400 KB Output is correct
18 Correct 2 ms 396 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 296 KB Output is correct
24 Correct 2 ms 360 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 2 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 544 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 4 ms 632 KB Output is correct
35 Correct 3 ms 504 KB Output is correct
36 Correct 4 ms 764 KB Output is correct
37 Correct 9 ms 760 KB Output is correct
38 Correct 5 ms 760 KB Output is correct
39 Correct 5 ms 632 KB Output is correct
40 Correct 4 ms 504 KB Output is correct
41 Correct 4 ms 632 KB Output is correct
42 Correct 4 ms 632 KB Output is correct
43 Correct 5 ms 760 KB Output is correct
44 Correct 5 ms 888 KB Output is correct
45 Correct 5 ms 888 KB Output is correct
46 Correct 7 ms 1144 KB Output is correct
47 Correct 5 ms 1176 KB Output is correct
48 Correct 7 ms 1016 KB Output is correct
49 Correct 6 ms 1016 KB Output is correct
50 Correct 5 ms 888 KB Output is correct
51 Correct 5 ms 888 KB Output is correct
52 Correct 6 ms 1016 KB Output is correct
53 Correct 6 ms 1016 KB Output is correct
54 Correct 6 ms 1144 KB Output is correct
55 Correct 10 ms 1528 KB Output is correct
56 Correct 33 ms 5176 KB Output is correct
57 Correct 64 ms 8416 KB Output is correct
58 Correct 79 ms 10848 KB Output is correct
59 Correct 107 ms 14196 KB Output is correct
60 Correct 150 ms 17500 KB Output is correct
61 Correct 141 ms 20008 KB Output is correct
62 Correct 193 ms 22124 KB Output is correct
63 Correct 217 ms 26204 KB Output is correct
64 Correct 248 ms 27244 KB Output is correct
65 Correct 100 ms 13432 KB Output is correct
66 Correct 93 ms 13560 KB Output is correct
67 Correct 100 ms 13560 KB Output is correct
68 Correct 207 ms 25964 KB Output is correct
69 Correct 234 ms 27524 KB Output is correct
70 Correct 214 ms 27396 KB Output is correct
71 Correct 284 ms 47300 KB Output is correct
72 Correct 281 ms 47400 KB Output is correct
73 Correct 256 ms 43964 KB Output is correct
74 Correct 267 ms 44556 KB Output is correct
75 Correct 273 ms 43128 KB Output is correct
76 Correct 258 ms 43112 KB Output is correct
77 Correct 261 ms 42528 KB Output is correct
78 Correct 265 ms 42472 KB Output is correct
79 Correct 260 ms 41312 KB Output is correct