QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623622#8707. JobsDimash#43 434ms416060kbC++231.6kb2024-10-09 13:28:402024-10-09 13:28:43

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 13:28:43]
  • 评测
  • 测评结果:43
  • 用时:434ms
  • 内存:416060kb
  • [2024-10-09 13:28:40]
  • 提交

answer

#include <bits/stdc++.h>
    
using namespace std;
    
typedef long long ll;
const int  N = 3e5 + 12, MOD = (int)1e9 + 7;

#define int ll
int n, p[N], x[N];
ll s, d[N];
vector<int> g[N], rt, ord[N];

void prec(int v) {
    d[v] = x[v];
    for(int to:g[v]) {
        prec(to);
        if(d[to] < 0) continue;
        d[v] += d[to];
    }
}
deque<pair<ll, ll>> deq[N];
void dfs(int v) {
    if(d[v] < 0) return;
    deque<pair<ll ,ll>> f;
    for(int to:g[v]) {
        dfs(to);
        deque<pair<ll, ll>> nv;
        int l = 0, r = 0;
        while(l < (int)f.size() || r < (int)deq[to].size()) {
            if(l == (int)f.size() || (r != deq[to].size() && deq[to][r].second >= f[l].second)) {
                nv.push_back(deq[to][r]);
                r++;
            } else {
                nv.push_back(f[l]);
                l++;
            }
        }
        f = nv;
    }
    ll val = x[v], mn = min(0ll, val);
    while(val < 0) {
        mn = min(mn, val + f[0].second);
        val += f[0].first;
        f.pop_front();
    }
    f.push_front({val, mn});
    deq[v] = f;
}
void test() {
    cin >> n >> s;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> p[i];
        g[p[i]].push_back(i);
    }
    prec(0);
    dfs(0);
    ll st = s, en = s, mx = s;
    for(auto [x, y]:deq[0]) {
        if(en + y < 0) {
            break;
        }
        en += x;
    }
    cout << en - st << '\n';
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); 

    int t = 1; 
    // cin >> t;

    while(t--) 
        test();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 11
Accepted
time: 353ms
memory: 416060kb

input:

299955 1000000000000000000
-2 0
10 1
-9 2
14 3
-11 4
17 5
-21 6
22 7
-22 8
23 9
-41 10
-89 10
49 11
99 12
-120 14
-23 8
130 15
24 16
-51 13
55 19
-144 20
-24 18
-30 18
-54 13
64 24
-105 14
145 21
-60 20
-183 25
61 28
-334 30
340 31
111 26
-135 33
-184 33
191 35
-231 17
-505 27
-570 32
-257 25
238 37...

output:

551168

result:

ok single line: '551168'

Test #2:

score: 11
Accepted
time: 434ms
memory: 390096kb

input:

299932 1000000000000000000
-26 0
-38 0
-521 0
-567 0
-569 0
-235 0
-294 0
-134 0
144 8
-177 0
-458 0
-9675 9
296 7
-15 0
34 1
-21349 9
-15643 9
-280 0
-445 15
-13253 13
-7497 15
-12328 15
-3131 15
7498 21
-172566 24
-14287 13
-24726 13
-1 0
-12603 13
-14221 13
-401 0
-4105 13
-2872 15
-1264 9
-5095 ...

output:

797403

result:

ok single line: '797403'

Test #3:

score: 0
Time Limit Exceeded

input:

299978 1000000000000000000
-319087 0
-397343 0
-746276 0
-123466 0
-27323 0
-462189 0
-44293 0
-157047 0
-492663 0
-471747 0
-214986 0
-276045 0
-134544 0
-245003 0
-564286 0
-100579 0
-128044 0
-725767 0
-317957 0
-515861 0
-209544 0
-152961 0
-275236 0
-499829 0
-609630 0
-439399 0
-61718 0
-80829...

output:


result:


Subtask #2:

score: 14
Accepted

Test #14:

score: 14
Accepted
time: 39ms
memory: 212348kb

input:

17 5
-3 0
4 1
-4 2
9 3
-5 4
13 5
-6 6
8 7
-23 8
28 9
-26 10
31 11
-28 12
33 13
-39 14
41 15
-7 16

output:

16

result:

ok single line: '16'

Test #15:

score: 14
Accepted
time: 47ms
memory: 213284kb

input:

17 1
-14 0
21 1
-15 2
16 3
-22 4
29 5
-32 6
34 7
-33 8
35 9
-10 10
-1 0
6 12
-3 13
5 14
-16 15
22 16

output:

7

result:

ok single line: '7'

Test #16:

score: 14
Accepted
time: 44ms
memory: 212976kb

input:

17 4
-4 0
12 1
-5 0
8 3
-13 0
17 5
-38 6
39 7
-3 8
-6 0
12 10
-29 11
35 12
-32 13
39 14
-24 0
31 16

output:

42

result:

ok single line: '42'

Test #17:

score: 14
Accepted
time: 40ms
memory: 212624kb

input:

1998 100000
-119974094 0
120949782 1
-148267915 2
149258545 3
-353200332 4
353781482 5
-409351160 0
410180396 7
-405293412 0
405638769 9
-491561775 0
492142804 11
-38208552 0
38786890 13
-188326000 0
188960234 15
-294174444 16
294530806 17
-430597876 18
431035538 19
-487343715 20
487438668 21
-17231...

output:

33581034

result:

ok single line: '33581034'

Test #18:

score: 14
Accepted
time: 64ms
memory: 226612kb

input:

1996 100000
-59755 0
151138 1
-174993 2
255152 3
-257624 4
322787 5
-293552 6
392535 7
-350940 8
418275 9
-487611 10
515476 11
-507579 12
556319 13
-549422 14
556127 15
-584293 16
638017 17
-613793 18
628801 19
-653479 20
704157 21
-695266 22
732277 23
-727516 24
792824 25
-781086 26
819574 27
-8098...

output:

23781881

result:

ok single line: '23781881'

Test #19:

score: 14
Accepted
time: 55ms
memory: 220792kb

input:

1996 83074
-104912 0
157516 1
-226832 2
244272 3
-236577 4
251249 5
-345494 6
411376 7
-527443 8
582958 9
-583787 10
665523 11
-681920 12
727305 13
-730788 14
757169 15
-844569 16
893388 17
-871493 18
916618 19
-1019572 20
1118628 21
-1135127 22
1163326 23
-1294857 24
1367717 25
-1345986 26
1391230 ...

output:

48888408

result:

ok single line: '48888408'

Test #20:

score: 14
Accepted
time: 40ms
memory: 216048kb

input:

1997 392026
-368613 0
553533 1
-8120957 2
8333895 3
-7985911 4
3312802 5
4435825 6
18517 7
-1014196 8
-10212556 9
11612664 10
-13466519 11
14039962 12
-21043407 13
21174643 14
-21449184 15
22266444 16
-31562006 17
31769754 18
-33458430 19
33563104 20
-34071074 21
34188004 22
-34242437 23
34307017 24...

output:

423307544

result:

ok single line: '423307544'

Test #21:

score: 14
Accepted
time: 44ms
memory: 213368kb

input:

1998 3670
-4263584 0
4318213 1
-4766861 2
4793818 3
-6021755 4
6028915 5
-10981412 6
11043466 7
-14917467 8
14928380 9
-18108504 10
18125244 11
-23575827 12
23586895 13
-24056708 14
24132173 15
-25452036 16
25510395 17
-36702348 18
36770088 19
-37159186 20
37165482 21
-38084372 22
38124010 23
-40075...

output:

30157547

result:

ok single line: '30157547'

Test #22:

score: 14
Accepted
time: 51ms
memory: 214332kb

input:

1996 100000
-47319305 0
47364706 1
-13725945 0
13780218 3
-24704817 4
24745187 5
-44323181 0
44421117 7
-5595173 0
5676261 9
-16802773 10
16822863 11
-8972006 0
8976861 13
-4882300 0
4967180 15
-19353494 16
19362861 17
-7345443 0
7410858 19
-21922402 20
21943524 21
-28082838 22
28092936 23
-41738649...

output:

28784257

result:

ok single line: '28784257'

Test #23:

score: 14
Accepted
time: 72ms
memory: 213028kb

input:

1996 954331
-246525934 0
246824973 1
-171768374 0
171931727 3
-277027442 4
277822284 5
-309469868 6
309597847 7
-285885388 8
-122289714 9
408353344 10
-449147475 11
449304397 12
-99137909 0
99891216 14
-388030661 15
388769528 16
-441565178 17
441709887 18
-53104970 0
53516386 20
-153117624 21
153153...

output:

39368059

result:

ok single line: '39368059'

Test #24:

score: 14
Accepted
time: 51ms
memory: 229336kb

input:

1996 1
-1 0
934596 1
-245994 2
838558 3
-1023435 4
1505077 5
-1253667 6
1510233 7
-1269836 8
1613725 9
-1505401 10
2178612 11
-2036205 12
2410454 13
-4326153 14
4947830 15
-4326154 16
4839162 17
-4352027 18
5026619 19
-4422789 20
4570760 21
-4868075 22
5163827 23
-5607853 24
6199786 25
-6221258 26
6...

output:

3656716

result:

ok single line: '3656716'

Test #25:

score: 14
Accepted
time: 52ms
memory: 222056kb

input:

1997 1
-1 0
4128 1
-3993 2
74560 3
-4107 4
29412 5
-124282 6
167990 7
-266635 8
285731 9
-296541 10
359960 11
-345943 12
403009 13
-559702 14
590908 15
-645298 16
667991 17
-713997 18
770876 19
-724771 20
761259 21
-745145 22
841278 23
-1132098 24
1209778 25
-1149601 26
1169460 27
-1207652 28
124597...

output:

1976688

result:

ok single line: '1976688'

Test #26:

score: 14
Accepted
time: 55ms
memory: 216352kb

input:

1997 221858
-906800 0
1458469 1
-3490423 2
4305248 3
-7528333 4
8000537 5
-7885388 6
7958703 7
-11393926 8
11980747 9
-11747944 10
12721208 11
-17195863 12
17436265 13
-19104428 14
19963703 15
-19221213 16
19790185 17
-26786612 18
27186963 19
-30098944 20
30428098 21
-30159706 22
30725701 23
-345052...

output:

471142643

result:

ok single line: '471142643'

Test #27:

score: 14
Accepted
time: 51ms
memory: 213960kb

input:

1996 849690
-28008524 0
28806149 1
-60092337 2
60377234 3
-86664447 4
86839975 5
-88838841 6
89792065 7
-118219083 8
118579228 9
-130374280 10
130705881 11
-184972834 12
185236973 13
-213002399 14
213944112 15
-225039106 16
225182999 17
-225237975 18
225413754 19
-234633304 20
234637320 21
-25407696...

output:

361576027

result:

ok single line: '361576027'

Test #28:

score: 14
Accepted
time: 51ms
memory: 212908kb

input:

1997 119135
-152044487 0
152804173 1
-397670939 2
397750796 3
-376672967 0
376746022 5
-417762437 6
418515035 7
-34613749 0
34835024 9
-414368835 0
414736822 11
-376229751 0
376495945 13
-384945031 14
385225811 15
-12089459 0
12451971 17
-389844127 18
390409800 19
-273473837 0
274006345 21
-15884699...

output:

27348525

result:

ok single line: '27348525'

Test #29:

score: 14
Accepted
time: 48ms
memory: 214080kb

input:

1998 942452
-17200029 0
17682105 1
-157988703 2
158288198 3
-4465812 0
4520447 5
-83969677 6
84083777 7
-377563619 8
378402838 9
-179102286 0
179287702 11
-182471742 12
182476796 13
-306751887 14
307033334 15
-459185361 16
460089539 17
-264044243 0
264411886 19
-299850633 20
300594894 21
-181708015 ...

output:

451229996

result:

ok single line: '451229996'

Test #30:

score: 14
Accepted
time: 76ms
memory: 227140kb

input:

1997 111
-71 0
70 1
0 2
0 3
-44 4
-61 5
26570 6
-108 7
19586 8
-109 9
77880 10
-110 11
8653 12
-111 13
84092 14
-39918 15
99150 16
-59706 17
95315 18
-128192 19
215712 20
-130737 21
132166 22
-250104 23
349032 24
-254356 25
304569 26
-273875 27
339811 28
-336187 29
355943 30
-404056 31
495501 32
-38...

output:

7053779

result:

ok single line: '7053779'

Test #31:

score: 14
Accepted
time: 51ms
memory: 219012kb

input:

1998 23414
-21438 0
65346 1
-21835 2
97920 3
-23231 4
61068 5
-173492 6
259764 7
-298330 8
340444 9
-314229 10
392678 11
-337064 12
411806 13
-377880 14
439107 15
-407467 16
481499 17
-473066 18
481956 19
-653829 20
706334 21
-1121383 22
1176305 23
-1143687 24
1168817 25
-1282829 26
1291310 27
-1289...

output:

42402445

result:

ok single line: '42402445'

Test #32:

score: 14
Accepted
time: 47ms
memory: 216240kb

input:

1996 82712
-316962 0
348266 1
-656551 2
664343 3
-1202654 4
1206638 5
-2231912 6
2292459 7
-3208507 8
3265411 9
-3283532 10
3290943 11
-3296785 12
3322367 13
-3355692 14
3432232 15
-3603791 16
3664502 17
-3791800 18
3846615 19
-4202013 20
4282980 21
-4239315 22
4286812 23
-4585108 24
4683584 25
-464...

output:

49210123

result:

ok single line: '49210123'

Test #33:

score: 14
Accepted
time: 51ms
memory: 214096kb

input:

1996 412723
-1285799 0
-2785143 1
-1915618 2
-31151 3
-10385 4
-352 5
-834 6
-271 7
-56 8
2286147 9
-1990814 10
-3346 11
-267118 12
-8046 13
-1982 14
-11516 15
-1886 16
5486951 17
-5461283 18
-14404 19
-8792 20
-2625 21
-1260 22
-50 23
-7 24
-5 25
-4 26
-2 27
-5 28
-1 29
6722984 30
-14074029 31
1421...

output:

274648629

result:

ok single line: '274648629'

Test #34:

score: 14
Accepted
time: 40ms
memory: 213392kb

input:

1996 96055
-163124760 0
163196597 1
-439679475 0
440015968 3
-330108552 0
330659538 5
-133814317 0
134036406 7
-361200860 0
361857023 9
-448386315 10
448562742 11
-305879265 0
306771045 13
-21948420 0
22559969 15
-444868398 0
445604686 17
-79688092 0
80526514 19
-161275407 20
162273868 21
-378895805...

output:

217568388

result:

ok single line: '217568388'

Test #35:

score: 14
Accepted
time: 55ms
memory: 213220kb

input:

1998 53059
-17596215 0
17635693 1
-24626608 2
24636115 3
-42169815 4
42235610 5
-48165922 6
48208633 7
-5034181 0
5043935 9
-44483459 10
44555839 11
-9484773 0
9498470 13
-17554127 14
17624124 15
-18632954 16
18643094 17
-11271715 0
11354481 19
-26953622 20
26963318 21
-27911140 0
28010094 23
-33163...

output:

47280019

result:

ok single line: '47280019'

Test #36:

score: 14
Accepted
time: 52ms
memory: 229312kb

input:

1998 100000
-36651 0
79063 1
-66318 2
116300 3
-94671 4
192399 5
-96166 6
121962 7
-99408 8
192332 9
-99527 10
165939 11
-99979 12
162744 13
-99990 14
178653 15
-99995 16
153909 17
-99997 18
102347 19
-99999 20
118015 21
-100000 22
185649 23
-546732 24
547012 25
-120651 26
-200831 27
276570 28
-2039...

output:

33334487

result:

ok single line: '33334487'

Test #37:

score: 14
Accepted
time: 56ms
memory: 221064kb

input:

1998 2750
-2674 0
939050 1
-2698 2
188682 3
-2750 4
349736 5
-76242 6
769422 7
-196140 8
736133 9
-223700 10
677360 11
-464369 12
1046139 13
-954432 14
1062023 15
-2825470 16
3729410 17
-3055569 18
3526003 19
-5955115 20
6192412 21
-8330959 22
8467897 23
-8435464 24
8650112 25
-8500021 26
8610167 27...

output:

62813522

result:

ok single line: '62813522'

Test #38:

score: 14
Accepted
time: 55ms
memory: 215772kb

input:

1996 9484
-482266 0
571044 1
-644059 2
734857 3
-1903590 4
1913094 5
-1969178 6
2030836 7
-2700941 8
2787436 9
-2758519 10
2857182 11
-2817204 12
2902534 13
-3223663 14
3271392 15
-3228009 16
3290047 17
-3937562 18
4026698 19
-3942339 20
3957812 21
-4035116 22
4101986 23
-4362539 24
4395213 25
-4416...

output:

10779086

result:

ok single line: '10779086'

Test #39:

score: 14
Accepted
time: 40ms
memory: 213928kb

input:

1996 43507
-43499 0
74123 1
-4468514 2
4560077 3
-7686298 4
7774199 5
-10115287 6
10210356 7
-15544964 8
15576507 9
-15914328 10
15990423 11
-16194873 12
16267151 13
-17397927 14
17456031 15
-17668924 16
17741741 17
-19882595 18
19960608 19
-21749798 20
21831533 21
-22366924 22
22432174 23
-26775628...

output:

9707042

result:

ok single line: '9707042'

Test #40:

score: 14
Accepted
time: 40ms
memory: 212844kb

input:

1998 16132
-27815063 0
27845919 1
-16124 0
70139 3
-543295 4
564956 5
-43991673 0
44070836 7
-861535 0
892306 9
-27107826 10
27120048 11
-29224292 12
29297130 13
-27370277 0
27442809 15
-38643375 16
38698533 17
-33817752 0
33905960 19
-1485102 0
1495381 21
-41707228 0
41800507 23
-30740171 0
3077709...

output:

6188757

result:

ok single line: '6188757'

Test #41:

score: 14
Accepted
time: 60ms
memory: 221168kb

input:

1991 35671
-22386 0
40467 1
-193576 2
204855 3
-291681 4
353201 5
-353949 6
362997 7
-367838 8
422419 9
-438001 10
530583 11
-473090 12
556111 13
-557456 14
649915 15
-628847 16
711329 17
-738620 18
792063 19
-834325 20
868739 21
-872848 22
963283 23
-896848 24
969140 25
-1001626 26
1073886 27
-1079...

output:

46098536

result:

ok single line: '46098536'

Subtask #3:

score: 0
Time Limit Exceeded

Test #42:

score: 0
Time Limit Exceeded

input:

300000 0
-1677 0
1678 1
-3010 2
3011 3
-8141 4
8142 5
-11233 6
11234 7
-14400 8
14401 9
-17045 10
17046 11
-19521 12
19522 13
-23178 14
23179 15
-26907 16
26908 17
-28884 18
28885 19
-30742 20
30743 21
-35957 22
35958 23
-38436 24
38437 25
-39739 26
39740 27
-42432 28
42433 29
-47866 30
47867 31
-48...

output:


result:


Subtask #4:

score: 29
Accepted

Dependency #2:

100%
Accepted

Test #76:

score: 29
Accepted
time: 36ms
memory: 213088kb

input:

6 1
3 0
-3 1
-5 0
2 1
6 3
-4 5

output:

6

result:

ok single line: '6'

Test #77:

score: 29
Accepted
time: 51ms
memory: 213428kb

input:

1992 100000
-123091 0
-30281 0
-21906 2
171526 1
-164573 4
78303 3
-539585 6
170968 5
-178934 6
-508341 8
-475191 8
518159 11
636961 7
-1375943 12
-1134601 13
-310451 4
243776 9
-261962 17
331531 18
1201616 15
-1488800 19
519773 10
-1589229 12
-1624437 22
1636816 23
-604851 13
-2491287 20
338512 16
...

output:

29871319

result:

ok single line: '29871319'

Test #78:

score: 29
Accepted
time: 43ms
memory: 212956kb

input:

1995 100000
-100015 0
-100035 0
-100004 0
-100023 0
100023 1
-100324 5
-100105 5
-43606 0
100107 7
100013 3
-100079 10
100031 4
-100207 12
-100219 10
-102221 9
100224 14
-100359 5
-100113 10
-100242 10
-101073 16
100038 2
-101171 9
-100687 21
-100054 21
-100779 16
101080 20
-100081 5
100365 17
-1004...

output:

2706

result:

ok single line: '2706'

Test #79:

score: 29
Accepted
time: 48ms
memory: 213144kb

input:

1995 100000
-100874 0
-100123 0
-100279 0
-100025 0
-100033 0
-100128 0
-100352 0
100030 4
-100054 0
-100789 0
-100164 0
-100023 0
-100082 0
-100088 0
-100414 0
100883 1
-100106 0
-100132 0
-100210 0
-104174 16
-100573 0
-100043 0
-103937 8
-100089 0
100091 14
100039 5
-100198 0
-100039 0
100046 28
...

output:

241

result:

ok single line: '241'

Test #80:

score: 29
Accepted
time: 50ms
memory: 214304kb

input:

1991 7
-1255 0
-2528 0
-822 0
-388 0
-1441 0
-2254 0
-3839 0
-782 0
-2530 0
-1586 0
-844 0
-2370 0
-756 0
-1171 0
-3768 0
-1563 0
-2452 0
-1475 0
-4270 0
-2079 0
-599 0
-2220 0
-2065 0
-139 0
1596 10
-1211 0
-4231 0
-3256 0
-348 0
-2600 0
-2036 0
-2011 0
-3473 0
-2426 0
-614 0
-1640 0
-2614 0
-1797 ...

output:

4143

result:

ok single line: '4143'

Test #81:

score: 29
Accepted
time: 64ms
memory: 222932kb

input:

1994 98229
-25011 0
-28801007 0
28812436 2
31607 1
-98668 4
175546 5
-125883 6
135777 7
-10384621 4
-12045979 6
-187727 8
10448416 9
-46915950 8
47004608 13
206079 11
12137635 10
-17969925 15
18052237 17
-202812 15
284861 19
-10901049 20
10987634 21
-279111 20
373407 23
-37466576 24
37553653 25
-301...

output:

14506418

result:

ok single line: '14506418'

Test #82:

score: 29
Accepted
time: 48ms
memory: 220480kb

input:

1994 4
-1 0
-5 0
2 1
11 2
-13 4
15 5
-17 6
23 7
-10 4
-19 6
22 10
-29 11
38 12
-26 11
-41 13
-33 13
14 9
46 15
-48 18
30 14
35 16
55 19
-44 18
46 23
-55 22
64 25
-62 22
66 27
-70 28
74 29
-68 28
-79 30
75 31
88 32
-83 30
88 35
-97 36
98 37
-98 38
-93 36
-62 40
106 39
-1 41
-99 38
-15 41
23 45
9 43
-...

output:

5191

result:

ok single line: '5191'

Test #83:

score: 29
Accepted
time: 59ms
memory: 214592kb

input:

1933 100000
-17223 0
17227 1
-69253 2
-89374 2
69262 3
89381 4
-100011 6
100017 7
-100007 5
-100075 8
-100012 6
100015 9
100016 11
-100042 12
-100044 8
100046 14
-100021 13
100026 17
100047 15
-100083 19
-100051 16
100087 20
-100096 22
-100045 19
100059 21
100052 24
100085 10
-100061 25
-100354 27
-...

output:

1181

result:

ok single line: '1181'

Test #84:

score: 29
Accepted
time: 56ms
memory: 212860kb

input:

1988 1
-49 0
-9 0
-8 0
-38 0
51 1
46 4
-56 6
-214 5
-599 5
-211 5
-109 6
-80 0
-215 5
220 13
16 3
116 11
-1037 14
-1 0
-153 15
-451 5
215 8
-78 6
-3126 14
457 20
-1720 14
-344 5
-1883 16
609 9
162 19
-1076 16
87 22
-89 15
-1423 28
11 18
19 2
-92 15
1730 25
-792 28
-245 14
-11 34
-158 15
-415 6
-2401...

output:

4072

result:

ok single line: '4072'

Test #85:

score: 29
Accepted
time: 52ms
memory: 213436kb

input:

1996 1
-155 0
-890 0
-60 0
-410 0
-264 0
-76 0
-72 0
-181 0
418 4
-47 0
-1805 9
-40 0
-9 0
-188 0
-1815 9
190 14
-130 0
-3715 16
-400 16
19 13
-874 16
879 21
3720 18
-751 0
-100 0
-437 0
47 12
-788 27
-71 0
78 29
-224 0
-133 27
-2458 16
759 24
-1368 9
-1470 16
-1827 30
-3286 30
-251 0
-2012 27
-2908...

output:

1797

result:

ok single line: '1797'

Test #86:

score: 29
Accepted
time: 64ms
memory: 212924kb

input:

1994 65443
-38003318 0
-18751475 0
-9734401 0
-18645890 0
-15668970 0
-17905454 0
-6796761 0
9812780 3
-20552708 0
-27344191 0
-12387671 0
-19533911 0
-8278752 0
-8310591 0
-16585891 0
-18322444 0
-28482172 0
-11198931 0
-21697231 0
-19967830 0
-1513124 0
-4799039 0
-9896868 0
-7389109 0
18344759 16...

output:

39365641

result:

ok single line: '39365641'

Test #87:

score: 29
Accepted
time: 52ms
memory: 219708kb

input:

1901 100000
-104214 0
104219 1
-46319 0
46328 3
-101616 4
-66898 4
66903 6
-102765 7
-86535 7
101618 5
102773 8
86537 9
-104225 12
104226 13
-100015 12
100023 15
-100777 16
100784 17
-100018 16
100025 19
-100020 20
-100959 20
100965 22
100027 21
-100023 24
-101058 24
101060 26
100030 25
-100278 28
1...

output:

1196

result:

ok single line: '1196'

Test #88:

score: 29
Accepted
time: 55ms
memory: 217164kb

input:

1898 9
-9 0
16 1
-8 0
-19 2
15 3
-10 2
17 6
21 4
-33 8
37 9
-29 8
32 11
-40 10
-39 10
42 14
42 13
-49 16
-42 16
56 17
-51 19
-55 19
64 21
58 20
48 18
-56 22
-61 22
64 25
63 26
-87 28
-71 28
93 29
77 30
-90 31
95 33
-91 31
93 35
-98 36
102 37
-95 36
100 39
-107 38
-110 38
115 42
-114 43
-112 43
121 4...

output:

957

result:

ok single line: '957'

Test #89:

score: 29
Accepted
time: 43ms
memory: 214272kb

input:

1994 100000
-82876 0
173951 1
-91781 2
162991 3
-372977 4
471319 5
-97733 2
-405921 6
-79149 0
491609 8
132818 7
-443797 11
480621 12
-670304 13
719700 14
-1417516 15
-675583 15
-491916 10
726063 17
121319 9
1496966 16
-1213898 19
1267835 22
-4905568 19
-481426 13
512055 25
-3133440 21
-5448924 26
-...

output:

34358020

result:

ok single line: '34358020'

Test #90:

score: 29
Accepted
time: 66ms
memory: 213292kb

input:

1992 4
-13 0
-1 0
-18 0
-2 0
-8 0
18 1
-160 6
-281 6
289 8
-10 0
-266 6
-321 6
11 10
12 5
-9 14
-78 13
-197 6
-1475 9
-2148 9
1484 18
165 7
274 11
4 2
-349 21
-1158 22
21 3
1167 25
-88 13
-1389 21
-129 26
-484 9
11 15
-153 26
-22 6
-791 22
82 16
204 17
-206 32
-344 23
-199 14
354 39
92 28
-745 21
-2...

output:

2570

result:

ok single line: '2570'

Test #91:

score: 29
Accepted
time: 51ms
memory: 213204kb

input:

1990 100000
-100242 0
-100942 0
-100115 0
-100204 0
-100144 0
-100325 0
-100071 0
-100655 0
-100479 0
-51715 0
-100228 0
100331 6
100145 5
-100223 0
-100635 0
100123 3
-101264 13
-100030 0
-101712 12
-100042 0
-103222 16
-100771 13
-104218 13
-105562 13
-104492 16
-59480 0
-100609 16
100236 11
-1005...

output:

2661

result:

ok single line: '2661'

Test #92:

score: 29
Accepted
time: 58ms
memory: 212896kb

input:

1996 5
-98 0
-2663 0
-2375 0
-3018 0
-2217 0
-1570 0
-172 0
-1132 0
-3560 0
-1926 0
-482 0
-299 0
-1811 0
-29 0
-103 0
-3084 0
-1743 0
-3269 0
-3583 0
-1323 0
-595 0
-194 0
2666 2
1928 10
-651 0
-1488 0
-2823 0
-2661 0
-3897 0
1751 17
-162 0
-2317 0
-2417 0
-3261 0
-2819 0
-2235 0
-906 0
-3135 0
-16...

output:

3215

result:

ok single line: '3215'

Test #93:

score: 29
Accepted
time: 72ms
memory: 220636kb

input:

1991 1
-1 0
-2078 0
2080 2
11 1
-1927 4
-3 4
13 6
1937 5
-592 7
596 9
-11 7
16 11
-12 12
19 13
-2820 12
-1131 14
2822 15
-13 14
1136 16
16 18
-1634 20
-22 20
32 22
1635 21
-1997 23
-25 23
2000 25
29 26
-3032 28
3041 29
-30 28
32 31
-3523 32
3528 33
-31 32
40 35
-32 36
33 37
-5014 36
5018 39
-1688 38...

output:

1386

result:

ok single line: '1386'

Test #94:

score: 29
Accepted
time: 47ms
memory: 220584kb

input:

1990 8477
-1790 0
-6417 0
40482 2
-76026 3
61501 1
-97265 3
115139 4
146268 6
-165045 8
-77341 8
-35192 10
-2259 10
94122 11
-32933 12
194078 9
82216 14
-225518 15
268342 17
-223711 15
-229725 18
258070 19
230454 20
-231987 18
234998 23
-1348 12
-31585 25
-246098 24
-240867 24
308003 28
-5342 25
-26...

output:

25076974

result:

ok single line: '25076974'

Test #95:

score: 29
Accepted
time: 48ms
memory: 213088kb

input:

1993 9
-2 0
-6 0
11 1
-3 3
4 4
12 2
-63 3
-9 6
-8 5
18 8
17 9
-13 10
-51 11
-21 10
-14 11
23 14
18 15
-68 17
-71 17
-37 16
54 13
-35 6
-50 5
56 23
-54 21
-28 16
70 18
-67 24
33 26
15 12
44 20
-571 29
79 19
-89 30
-104 24
-589 21
76 28
-116 31
591 36
-591 33
63 25
-113 37
599 40
-34 29
-74 31
-938 39...

output:

1661

result:

ok single line: '1661'

Test #96:

score: 29
Accepted
time: 55ms
memory: 213700kb

input:

1990 10
-13 0
-7 0
17 1
-28 3
-20 3
26 5
-34 6
-29 6
36 7
-101 9
29 4
-54 9
-56 11
38 8
-178 9
-39 3
10 2
61 12
65 13
49 16
-202 20
-8 17
-87 20
-491 11
-312 19
188 15
108 10
211 21
-51 20
-470 28
-596 19
97 23
321 25
-502 28
477 30
-148 19
-720 9
-203 28
-478 26
-481 27
486 40
-185 32
-837 19
-82 1...

output:

5478

result:

ok single line: '5478'

Test #97:

score: 29
Accepted
time: 52ms
memory: 213316kb

input:

1990 1
-447835 0
-22904 0
451584 1
-1075937 0
-209894 0
1133395 4
-28255892 6
-13465290 3
-19253160 6
-9596010 6
-670730 0
223447 5
-79860 0
-5831053 3
5875037 14
-3064880 0
-28333869 3
-14614820 12
3097823 16
-12462667 19
-104646 0
-9316745 3
-26666671 15
9631409 10
19298046 9
-6947631 12
91358 13
...

output:

4547747

result:

ok single line: '4547747'

Test #98:

score: 29
Accepted
time: 59ms
memory: 214404kb

input:

1992 2
-1136 0
-1858 0
-2221 0
-272 0
-660 0
-1441 0
-3372 0
-232 0
-1958 0
-870 0
-4135 0
-2445 0
-4453 0
-3653 0
-25 0
-974 0
-4395 0
-2344 0
-985 0
-3878 0
-2324 0
-3357 0
-1461 0
-1100 0
-3596 0
2453 12
-3128 0
-2879 0
-1365 0
-287 0
-1416 0
-3034 0
-5070 0
2885 28
-3040 0
-4627 0
-4096 0
-1116 ...

output:

5401

result:

ok single line: '5401'

Test #99:

score: 29
Accepted
time: 64ms
memory: 217328kb

input:

1899 9
-2324 0
2329 1
-4 0
6 3
-77 4
83 5
-8 4
13 7
-9 8
-604 8
15 9
-12 11
-1922 11
614 10
1931 13
17 12
-16 16
17 17
-2484 16
-18 18
-1430 18
26 20
2490 19
-1315 22
-20 22
1438 21
1318 24
22 25
-21 28
29 29
-1543 28
1550 31
-1923 30
-22 30
1930 33
24 34
-24 36
33 37
-954 38
-33 38
958 39
34 40
-41...

output:

2632

result:

ok single line: '2632'

Test #100:

score: 29
Accepted
time: 73ms
memory: 220836kb

input:

1994 1
-1 0
33087 1
-1873 0
26294 3
-45316 4
111450 5
-81782 4
140055 7
-84337 8
102494 9
-127807 8
156520 11
-213104 12
260132 13
-225971 14
-162552 12
-255980 14
228427 16
271795 17
-276631 19
-279249 19
357124 21
291810 20
-289568 22
375973 24
267507 15
-326270 22
393225 27
-341653 28
409817 29
-...

output:

19838070

result:

ok single line: '19838070'

Test #101:

score: 29
Accepted
time: 62ms
memory: 213056kb

input:

1998 23568
-5832 0
82071 1
-53571 0
-547083 2
-584455 2
141858 3
-365528 6
681182 5
-210886 0
-1234196 6
449414 7
-1718551 8
-300025 6
-497177 11
-129044 2
273861 9
359347 13
-4029992 11
-689408 16
-1138509 8
-1059685 17
1175015 20
1281016 10
-14825912 22
4118807 18
-4948702 22
-4503342 22
-2262698 ...

output:

49171083

result:

ok single line: '49171083'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%