QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#454548#531. GameRaduM90 1642ms4460kbC++201.1kb2024-06-25 03:06:322024-06-25 03:06:34

Judging History

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

  • [2024-06-25 03:06:34]
  • 评测
  • 测评结果:90
  • 用时:1642ms
  • 内存:4460kb
  • [2024-06-25 03:06:32]
  • 提交

answer

#pragma GCC optimize("Ofast,inline,unroll-loops")
#include <bits/stdc++.h>

using namespace std;
int v[100005];
int f[100005];
int semn[] = {1, -1};

int main()
{
    int n,i,k,t,x,e,s;
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for(i = 1; i <= n; i++) cin >> v[i];
    while(k--){
        s = t = 0;
        cin >> x;
        for(i = 1; i <= x; i++){
            f[v[i]]++;
            t = max(t, v[i]);
        }
        s = t;
        f[t]--;
        e = 1;
        while(t > 0 && f[t] == 0) t--;
        for(i = x + 1; i <= n; i++){
            if(v[i] > t) s += semn[e] * v[i];
            else{
                s += semn[e] * t;
                f[t]--;
                f[v[i]]++;
                while(t > 0 && f[t] == 0) t--;
            }
            e ^= 1;
        }
        while(t > 0){
            while(f[t] > 0){
                f[t]--;
                s += semn[e] * t;
                e ^= 1;
            }
            t--;
        }
        cout << s << "\n";
    }
    return 0;
}

详细

Test #1:

score: 5
Accepted
time: 0ms
memory: 3540kb

input:

7 4
4 6 7 3 4 7 4
6 3 1 2

output:

5
1
3
5

result:

ok 4 lines

Test #2:

score: 5
Accepted
time: 0ms
memory: 3612kb

input:

10 10
10 1 4 2 8 7 3 3 10 2
10 7 6 8 5 1 4 3 9 2

output:

4
8
2
4
14
20
0
16
4
-2

result:

ok 10 lines

Test #3:

score: 5
Accepted
time: 1ms
memory: 3632kb

input:

208 150
125 187 27 147 175 94 72 45 63 192 52 178 44 88 64 184 203 52 89 176 96 141 180 49 83 21 106 92 207 102 152 156 198 89 145 114 78 56 137 90 112 84 197 177 39 29 196 106 63 155 184 33 105 84 48 83 154 17 134 98 207 147 16 10 104 30 12 77 95 189 29 31 61 79 28 50 91 181 10 13 113 154 44 5 3 11...

output:

82
674
86
120
-46
106
196
98
184
158
158
264
104
90
154
192
146
168
108
-76
-574
442
62
606
168
48
98
-394
14
230
162
102
92
384
96
682
100
28
100
42
88
-400
238
90
138
92
54
98
-530
6
210
-526
668
20
98
202
276
46
-82
186
0
180
86
90
-130
28
98
126
20
166
100
-6
86
92
300
-522
44
224
266
-168
100
2...

result:

ok 150 lines

Test #4:

score: 5
Accepted
time: 0ms
memory: 3632kb

input:

540 26
52 170 275 477 413 99 417 427 104 32 198 102 23 67 178 152 43 434 251 394 281 97 85 66 313 79 373 462 340 477 461 418 214 379 152 349 2 255 106 168 444 241 32 56 320 464 59 269 65 475 178 98 534 144 320 330 211 143 313 140 87 44 458 309 73 126 307 41 307 348 306 523 454 347 265 307 393 214 61...

output:

268
286
-1466
1680
-1296
268
-1128
-1214
-1178
1522
1890
1788
774
-1358
-1042
1724
-1244
-1308
100
268
212
-1042
268
1020
1644
1746

result:

ok 26 lines

Test #5:

score: 5
Accepted
time: 1ms
memory: 3536kb

input:

542 251
369 463 53 164 490 18 144 87 488 289 501 72 308 115 164 281 204 456 179 439 332 395 342 340 121 192 87 487 493 13 222 129 361 457 286 6 369 306 209 488 464 530 374 364 171 490 292 181 443 343 256 311 505 358 472 193 27 424 25 42 462 261 358 440 311 370 15 168 27 178 511 140 188 265 440 20 18...

output:

518
-194
-88
-2326
-2318
4
74
1622
518
-704
88
314
-2174
0
-210
82
-286
1064
426
858
1454
-324
148
526
-1472
2892
464
-124
-560
868
706
778
2712
254
578
-428
-2118
590
22
-2046
222
436
-216
-124
-598
-288
-186
550
4
1334
784
868
488
-184
-36
-336
862
-14
-170
1140
-28
72
-2242
-830
286
2356
544
-223...

result:

ok 251 lines

Test #6:

score: 5
Accepted
time: 0ms
memory: 3680kb

input:

600 600
340 371 504 42 128 427 573 233 200 242 413 9 471 104 512 31 133 480 596 481 317 599 433 450 485 358 303 315 255 281 372 127 450 198 182 156 146 117 7 473 212 530 390 5 365 372 46 80 589 264 467 539 58 204 424 564 207 87 517 181 68 346 596 556 432 552 139 324 428 550 232 235 529 288 103 378 4...

output:

-1225
-1021
-327
893
1387
185
-2055
343
309
-771
-409
529
487
-539
1575
-619
287
287
869
-963
397
305
-197
-1245
-741
1693
-513
-877
287
287
101
315
1505
1499
891
-485
515
175
-1611
-2693
-1833
2451
277
1545
-565
279
1365
277
-2649
-1233
287
-1133
1711
1725
561
-171
-1205
-567
287
-809
-599
2987
-25...

result:

ok 600 lines

Test #7:

score: 5
Accepted
time: 16ms
memory: 3648kb

input:

3646 741
1632 1042 1349 950 1312 1706 1640 2509 111 2065 1226 3584 3258 2561 547 2269 1028 760 451 3546 3091 1556 3055 174 1986 2618 307 2510 1226 1884 3043 952 3521 2933 2699 3473 575 1606 739 189 1262 3312 3587 3619 826 3103 2342 1421 2800 2223 3271 1595 1095 1938 413 1623 1076 1194 2964 3036 3141...

output:

-7932
12510
3160
-1604
20496
-11196
-10754
1248
-1404
-2964
-2138
466
2830
-2760
2802
6860
-7364
1748
-8910
1790
4820
-1236
-808
15068
-17802
6970
2296
4968
16574
1980
-3638
1780
-6842
6386
-8030
-1234
-2686
22060
5198
-1906
12190
1780
-3318
898
1586
19648
1060
-1018
24678
1792
1846
1856
2618
-12620...

result:

ok 741 lines

Test #8:

score: 5
Accepted
time: 18ms
memory: 3640kb

input:

4769 584
4614 4214 1529 1987 1775 4543 601 2178 1328 3930 3512 425 759 1897 4512 640 4734 3665 2896 1117 2448 2087 896 1091 1353 2865 1866 3384 2427 2114 3292 3728 929 4607 826 3374 228 22 329 4696 533 1662 1256 2486 1195 4536 2758 4496 591 2809 3245 470 4165 999 1257 181 3632 3016 3909 4756 4047 10...

output:

-89488
66252
-6924
-25866
-47060
-125582
1696
2788
-96498
-117952
41540
-26710
2376
-115268
-10558
2946
2506
2738
-506
12474
-70914
93654
17226
4616
2912
-59520
-24080
-11484
24484
93770
3056
2026
7128
70906
2838
2412
107064
-90292
-89304
-95968
12780
93682
1268
1744
1976
84642
12088
92630
45698
751...

result:

ok 584 lines

Test #9:

score: 5
Accepted
time: 59ms
memory: 3780kb

input:

8692 977
2678 1481 4286 107 6908 7977 3115 4154 3742 7033 1699 1189 8293 3453 3792 4073 4921 2069 4563 7107 4367 4481 7084 604 6398 1766 3502 5487 5306 1162 1527 1068 7943 3243 1911 2067 1305 5550 1553 4165 4213 7894 6127 7108 1151 7721 1529 3689 592 1197 4818 364 2969 2581 4204 1349 6662 2179 589 8...

output:

25387
-1781
-1101
69857
104993
-28641
5109
31559
10497
-7635
-89851
-2081
-38891
6471
30325
4633
4371
74649
-447
-100229
34657
-33739
103825
3931
23401
-41251
47
19509
-3607
37917
10993
92511
102047
-102675
27421
73543
-62585
57959
-94493
38773
10513
-5093
10293
78767
106469
106835
-28011
4693
39951...

result:

ok 977 lines

Test #10:

score: 5
Accepted
time: 69ms
memory: 3684kb

input:

10000 1000
6960 5914 1055 2108 8306 566 9218 1023 6675 4653 4082 3332 9502 8501 6399 3247 5518 4224 8501 1702 5533 1416 9735 3338 1484 8634 8301 1922 4154 6938 1669 8026 6137 7649 3515 2895 4637 1602 8261 7629 1010 9776 4873 9353 8448 4065 2584 8083 5718 7161 1735 1989 5811 4740 3447 6511 7928 9506 ...

output:

36688
-189250
78954
-7568
-15856
191646
-105128
-89714
49150
-118558
4516
-23592
-205082
-78086
5652
122692
-10
6292
4820
-346206
-2940
2344
-85988
-3254
60680
43682
64334
-50796
83066
-110558
5058
5408
4566
-47156
212210
-43640
-190536
-181046
-3202
197174
43754
20998
-170484
-345140
-85230
93966
-...

result:

ok 1000 lines

Test #11:

score: 5
Accepted
time: 304ms
memory: 4028kb

input:

55611 668
46800 1695 50620 44613 1154 18115 50995 3389 22909 11534 35539 51505 39607 11955 25862 29524 55592 29742 30506 13219 17133 30478 13930 41617 29264 29638 8641 41537 29499 14196 21678 41371 36070 13117 54355 41185 17737 43443 6948 37969 49903 49328 29605 44556 35661 12680 35633 16127 11318 5...

output:

-2926424
-924974
3350360
1940270
-3159402
1264782
52528
368346
1469238
-739628
3474574
3492048
-1044398
2179434
2718688
-2393338
3028644
27354
-6868
3474564
235906
1993066
132516
284220
-3441436
2583702
-3434192
420224
976946
-3428344
-1451168
189270
-1324592
2033606
-346688
3171466
967674
3486124
3...

result:

ok 668 lines

Test #12:

score: 5
Accepted
time: 603ms
memory: 3956kb

input:

52357 1407
7246 34985 44509 7726 46136 28282 17060 18280 31592 24351 22419 33148 42574 3630 34875 7370 46951 10907 45794 19792 52112 5598 40584 44334 33680 2106 6367 43490 12891 26854 10036 4577 33683 12966 16469 11232 48344 32636 43654 25304 12280 26724 44129 48854 44405 37819 24491 20371 43177 427...

output:

102475
-333821
-1315403
-2207757
-54421
104951
46279
-241773
2875797
-280609
-97287
28151
268455
551033
-391545
-251195
-359153
269743
-246893
-536545
-494611
-2250731
578623
268531
179849
477477
255989
1342249
493855
492239
22943
-495475
540495
-241567
270249
186551
-209535
30501
-135205
-86697
613...

result:

ok 1407 lines

Test #13:

score: 5
Accepted
time: 414ms
memory: 3944kb

input:

50777 1005
3338 37282 31313 16624 17881 35902 27416 45991 30084 22711 44836 10954 32398 48698 46304 19678 39531 36928 34073 34734 18538 3020 4857 33709 15894 35988 32182 9561 50174 27323 11547 44506 8905 25308 35585 3132 17495 22526 38897 2881 33782 31339 21873 30342 13220 24646 4271 33489 50012 380...

output:

3254135
-57849
-3258057
-162557
-3036305
-60657
138799
235593
3329903
-3061905
25331
50399
-3174443
-3169653
-24629
183173
3273031
1933321
-2465553
77045
2791447
113023
-3185879
-2929815
626735
3333841
22823
89819
-3365097
-2276987
-817619
371455
498089
-270639
3101785
3447317
856171
-4915597
-32661...

result:

ok 1005 lines

Test #14:

score: 0
Wrong Answer
time: 265ms
memory: 3932kb

input:

83214 1643
60059 14 60054 8 60005 66 60017 23 60074 53 60081 32 60001 1 60098 47 60017 24 60000 2 60032 16 60034 38 60083 34 60000 22 60053 38 60068 26 60036 49 60014 95 60036 2 60060 29 60009 76 60072 53 60047 65 60083 83 60017 61 60034 89 60010 40 60046 11 60027 6 60025 78 60068 24 60019 38 60073 ...

output:

58441
1674810155
-153433
-1927300691
436025
58287
136181
1157775279
77315
1003863699
34395
448495
-1974366947
1863665179
87081
1420769543
-17915
-1367135031
60293
59949
-1349257387
-1063122931
33757
-16807
-416792419
-298926403
444431
234991
57793
-1685491107
58855
1800226829
-1825671005
58213
-1023...

result:

wrong answer 4th lines differ - expected: '2367666605', found: '-1927300691'

Test #15:

score: 5
Accepted
time: 575ms
memory: 4300kb

input:

90373 777
86561 52154 16914 68062 63554 72354 66583 54665 83913 64577 67490 19623 48478 50610 14198 44553 82153 87612 77258 43149 13302 65076 83167 18544 12611 9871 8948 8591 39374 78998 37480 50109 39599 29218 61550 42595 56586 56754 51124 16373 11270 83901 64601 64494 13514 3699 45153 22041 29204 ...

output:

-5045519
72365
143605
1402923
27865
-456733
44915
-182147
-232095
468671
-780621
-3611897
-609305
885213
-2560907
42283
1319041
196867
762679
-576007
370931
-214425
-49259
-501157
-1223339
-226297
-595459
-2026203
322129
-4639841
-334311
-117087
-290039
383531
-872215
36253
582651
-574727
841267
140...

result:

ok 777 lines

Test #16:

score: 5
Accepted
time: 796ms
memory: 4456kb

input:

94887 1017
75083 9965 90777 9423 49901 71161 36513 91887 78575 39609 27620 74307 71293 5317 22529 66351 87452 56887 41064 12607 22909 18520 80613 36943 50806 53164 77626 25461 84713 21109 67437 59187 79386 31806 53493 26680 68864 81224 63613 31662 58038 57795 4853 52219 8456 4391 49630 92081 204 173...

output:

7964338
-16237464
-6215612
4962114
56574
12970842
142812
9097866
4797600
1211854
31082
15821496
-14785586
-535446
-1782428
15179232
2754942
-1136040
753058
634684
49588
-9183826
-5013636
-495008
-3763206
213048
8020268
-8308258
11804534
-8205052
469524
6016532
-6778842
4943274
8258488
12101594
10689...

result:

ok 1017 lines

Test #17:

score: 0
Wrong Answer
time: 391ms
memory: 3992kb

input:

100000 2000
90029 24 90024 18 90005 26 90007 23 90024 13 90011 22 90011 11 90018 7 90007 14 90000 22 90022 16 90014 28 90013 14 90020 2 90013 28 90008 26 90016 9 90004 5 90026 2 90000 29 90009 26 90012 13 90027 25 90003 13 90007 11 90014 29 90000 10 90016 1 90007 26 90005 8 90028 14 90029 28 90003 2...

output:

-1382525050
-1931517450
-92438
30
-242539704
1734424034
-25424
1698932862
-35596
150802
76770
-61496
589557880
-159364
60
-1544527244
1799543980
-2
514
1474
851877424
1848900618
-2001669070
482538
-1493212832
-1768406780
109002
-56
-24274
44020
379175710
1451817414
15148
-14198
-10782
-28372
-87480
...

result:

wrong answer 2nd lines differ - expected: '2363449846', found: '-1931517450'

Test #18:

score: 5
Accepted
time: 1397ms
memory: 4220kb

input:

88209 1930
49243 24977 40855 77568 86233 15235 5688 75012 24839 50633 35287 26924 14358 37966 83843 69215 11245 17064 25529 16337 61108 17402 44284 35892 33069 45007 3898 48241 74490 64532 73788 11058 55791 66560 45241 51690 77627 54935 55994 72030 31858 55910 26169 404 29401 27575 5394 51638 78849 ...

output:

-3653877
45263
-1377009
-108573
-1151651
-6599021
43943
-6129069
-6392013
-215725
-7729263
114653
-2609127
3411205
144519
-7035021
-1786141
1336425
-7572759
282297
131139
-47933
1037987
-4785
6671927
-6136421
6947743
6530173
-7594145
2285847
-44137
-7850649
4093713
43275
-334231
-5206725
-200845
284...

result:

ok 1930 lines

Test #19:

score: 5
Accepted
time: 916ms
memory: 4288kb

input:

94404 1169
13456 9404 50594 65706 77387 9774 55846 3430 65110 87326 8231 6991 36393 28078 29414 71671 8080 11170 36357 68895 28943 64815 39098 55468 68490 58435 53625 45081 41917 11480 85417 66391 53323 37639 33024 78673 59304 16633 44689 94160 22351 12493 2450 23233 31834 8951 77458 24253 1533 4082...

output:

4929194
-4048048
3787528
-6905220
8339972
4885286
5257726
1713738
4739986
166172
262054
202322
47232
-75986
-2007200
956054
-2200860
120260
-7835822
-7003402
-2028680
168994
-4409794
4063612
121974
-629390
3497658
73242
-17852
969456
-6989462
2258952
-5638536
166424
-1652488
285532
-8443690
-7219572...

result:

ok 1169 lines

Test #20:

score: 5
Accepted
time: 1642ms
memory: 4460kb

input:

100000 2000
46960 15914 21055 72108 48306 80566 49218 81023 76675 44653 94082 53332 59502 78501 76399 13247 95518 14224 58501 51702 5533 71416 89735 93338 21484 88634 38301 91922 24154 56938 61669 88026 6137 37649 33515 22895 4637 61602 28261 17629 31010 29776 4873 39353 58448 74065 42584 78083 3571...

output:

4978688
-8516602
624114
47050
-11614208
9423830
-252192
-6035280
-18736
-1589380
-433806
373848
-3305870
1847418
52770
-10215880
-6418968
46964
99942
207482
11526440
8957662
7152240
-11887046
5322778
6409148
-771190
45240
-268980
-58962
-2783440
-5094314
484348
-391504
-433538
-186992
583280
-915511...

result:

ok 2000 lines