QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#298804#7768. Grievous LadyPassName4 1065ms7840kbC++141.4kb2024-01-06 14:52:072024-01-06 14:52:07

Judging History

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

  • [2024-01-06 14:52:07]
  • 评测
  • 测评结果:4
  • 用时:1065ms
  • 内存:7840kb
  • [2024-01-06 14:52:07]
  • 提交

answer

#include <bits/stdc++.h>

#define rint register int

#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 5;

int n, A, B;
int a[N], b[N], p[N];
int res;
bool in[N];

mt19937 rnd(time(0));
void solve() 
{
    int na = 0, nb = 0;
    
    for (rint i = 1; i <= n; i++)
    {
		if (!in[i]) na += a[i];
		else nb += b[i];
	}
    int now = na * nb;
    int times = 4e4 + 5;
	while (times--) 
	{
        int x = rand() % n + 1;
        if (!in[x]) 
		{
            if (now < ((na - a[x]) * (nb + b[x])))
            {
                in[x] ^= 1;
				na -= a[x]; 
				nb += b[x]; 
				now = na * nb;				
			}
        } 
		else 
		{
            if (now < (na + a[x]) * (nb - b[x]))
            {
                in[x] ^= 1;
				na += a[x]; 
				nb -= b[x];
				now = na * nb;				
			} 
        }
    }
    res = max(res, now);
}

void work() 
{
    for (rint i = 1; i <= n; i++)
    {
		cin >> a[i] >> b[i];
		p[i] = i;
	}
    res = 0;
    int times = 30;
    while (times--)
	{
        random_shuffle(p + 1, p + n + 1);
        for (rint i = 1; i <= n / 2; i++)
        {
			in[p[i]] = 1;
		}
		for (rint i = n / 2 + 1; i <= n; i++)
		{
			in[p[i]] = 0;
		}
        solve();
    }
    cout << res << endl;
}

signed main() 
{
    int T;
    cin >> T >> n >> A >> B;
    while (T--) work();
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 12
Accepted
time: 899ms
memory: 7704kb

input:

50 10 10000 10000
8450 6001
2804 803
8972 6155
8161 1938
4806 6582
2927 9312
9157 1289
6486 3737
8239 257
7292 9051
6079 2510
1408 5174
6821 772
8947 3187
100 5067
6986 9882
2067 1776
2734 6298
8909 4770
1083 1077
4929 4165
4788 5873
5490 6802
6829 6136
8919 4869
9488 4505
1052 8990
57 1445
7680 822...

output:

1356022774
902566854
1140061305
967802717
879903720
890841120
1080286757
1250989070
1362698900
1413511168
1137531330
775920120
934759445
981422955
1136968923
839143260
1277454816
522098415
1244442420
1173533392
899456910
665601553
1193825850
1122903576
845410521
1263368813
1302451776
811132751
10328...

result:

ok 50 lines

Test #2:

score: 0
Accepted
time: 901ms
memory: 5788kb

input:

50 10 10000 10000
9994 4842
1922 7614
1936 9958
9262 8443
8720 8834
7271 3310
3047 4277
1750 2453
6070 2889
3798 3031
2501 8157
5431 5964
6347 179
8316 176
6647 2595
3613 2724
9626 5687
4326 7389
5403 7261
2454 1235
5553 6024
8417 6403
7437 4767
3583 8990
7341 1101
5547 4696
9850 1151
9236 7642
9147...

output:

1205984720
1064613313
1181141416
745894788
954402457
1166670472
848497233
1220235285
749940533
1302492620
1201885634
1038468151
941992320
1232153580
957687204
1151181720
1415985570
843533980
1410180345
591520050
1187581494
1037049840
1125205536
1073427795
868248043
1476506400
606549255
1298210470
12...

result:

ok 50 lines

Test #3:

score: -12
Wrong Answer
time: 895ms
memory: 5672kb

input:

50 10 1000000000 1000000000
494574201 920783166
595927955 755325735
309577744 179185250
211824757 104989303
153612343 475522134
147518010 954162295
14870931 809174851
144588437 714960306
500467723 342648884
451897537 16352725
387829577 604905371
164562427 730017330
174013757 88116170
413352963 25848...

output:

8019248717016210432
9220523411708714666
8316256835644358400
9219876851521805472
9200628531425823442
9198560794269335280
9216701081898277968
9204589863361078720
9083188670108391940
9179100801695880454
9213931113214261590
9215778287681801746
9171336621925980171
8381947936335561125
9208201698900202418
...

result:

wrong answer 2nd lines differ - expected: '9562527646373455452', found: '9220523411708714666'

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 20
Accepted
time: 923ms
memory: 7840kb

input:

50 30 10000 10000
4853 6897
1727 7443
2329 2876
5355 3477
2872 4090
2719 1756
989 681
7909 4601
8835 4634
9358 3999
8141 3749
8476 9479
2527 8659
7238 5965
3058 2946
8 2928
8116 7269
3840 2790
422 930
2018 8310
1708 7842
3701 3484
2944 9028
4308 9528
4704 6890
7982 8335
1596 9290
7031 745
6121 7262
...

output:

9075997372
9741088812
10477290528
10327786031
9141835285
11432058683
10870358352
7778666504
9641567016
11776211156
10497065841
9179627443
9286255875
9491961765
10977950304
9468844866
10773619480
9039361190
10296624454
11768814156
9105586680
11348624584
12677685920
10307061072
9933184000
9600793237
9...

result:

ok 50 lines

Test #14:

score: 0
Accepted
time: 918ms
memory: 7716kb

input:

50 30 10000 10000
589 5738
8142 5742
6781 3575
6456 7279
1378 9046
7062 5754
2174 6372
3173 3317
6667 6050
3159 5276
4562 5204
2498 7165
6244 4962
6607 8762
5413 474
9339 4283
8379 6988
8137 1177
6915 3421
3389 8468
9229 9701
34 5502
9083 6993
1062 8190
3126 417
4041 1231
3097 1451
2018 4238
1780 16...

output:

9525996254
10892213498
10404171996
9081771489
11496784068
11078110925
8614479825
8945324070
10270120308
12448176883
9274530918
8957530754
10860447360
9184738320
8296323966
8312249517
9710416600
7810910448
10149108215
9764597076
11977831971
9486264928
9319753240
10409846790
8899503690
8889334266
9011...

result:

ok 50 lines

Test #15:

score: -20
Wrong Answer
time: 919ms
memory: 5788kb

input:

50 30 1000000000 1000000000
251485114 444587657
228926791 639208393
74483764 587762337
852967201 938371135
78981735 943523557
753951577 63154380
86269901 162534212
326503386 663502367
311244770 82095951
610254546 717995726
131711656 362793661
981001013 408326096
578856228 386961896
35934522 82007884...

output:

9215533829828344078
9220137636069967206
9210112441150803748
9214049738879745072
9221583922928914384
9222043738995474156
9221122365080793249
9221226533428379648
9221203191350998952
9217627671754859608
9220351642917730624
9219370391933388952
9220721092746551372
9222082915403438666
9220864786009506153
...

result:

wrong answer 1st lines differ - expected: '95513417737596173816', found: '9215533829828344078'

Subtask #3:

score: 4
Accepted

Test #33:

score: 4
Accepted
time: 933ms
memory: 7700kb

input:

50 100 10000 10000
3817 9367
533 166
3422 6775
1637 2003
4512 2346
7101 356
2772 4037
6684 180
8703 7518
4497 9606
9197 9761
7217 8544
332 7886
9189 4475
2622 7432
729 8677
3451 5287
8879 6942
4972 487
1370 3918
1009 5847
6307 2158
2380 9771
6296 9946
6644 2651
5624 5590
3171 1058
1608 8006
6185 687...

output:

99383125432
104811638659
112729256865
95121987940
118672536221
111893576256
104841972644
111108172500
123989724360
120695447525
104473835537
109353741512
112579826958
105383244393
110610633843
111211215702
111030606150
102942142176
103918702650
105812839958
121157116262
105484644782
125888304869
117...

result:

ok 50 lines

Test #34:

score: 0
Accepted
time: 938ms
memory: 7828kb

input:

50 100 10000 10000
3781 3549
3677 7205
3512 9016
1960 9921
4939 9905
2015 404
3416 4518
4193 1859
2560 7726
8718 4467
6613 6927
3339 7327
2623 1318
4002 9075
7352 211
5263 6083
9552 3402
7764 1397
8969 4275
5477 5458
8923 4314
2525 1209
2770 4400
9192 7181
5531 9272
4183 9202
2683 8571
3647 7987
240...

output:

112327572336
114293976410
117951056828
106767105004
112417001838
113939762280
107105545112
110511882647
115251735585
120655016004
112252156510
106001179508
123865980147
96991585712
105777760912
100592904627
108347998320
110198694780
99793026081
125554404780
109890923504
106931475391
113618517866
108...

result:

ok 50 lines

Test #35:

score: 0
Accepted
time: 931ms
memory: 5692kb

input:

50 100 100000 100000
24779 53022
10197 19663
8227 15511
13415 80908
44481 75266
68336 52768
28869 63344
62938 97846
97921 5700
68736 22955
25404 60053
32084 8593
74064 31247
6842 60910
40493 57042
43083 50778
66484 93970
44724 27813
45628 82517
91668 97870
86032 67448
35457 54253
65070 15339
84196 3...

output:

10467865569734
12760769817475
9553438423648
11505145748928
10952900162985
10352968744082
11009244465624
11117821946590
11628400689499
10818533551904
11194891139715
10833335223252
10565839978825
10551952240830
11304930499296
10050201697006
10840333479510
9762490127596
11242330198124
10947286769328
97...

result:

ok 50 lines

Test #36:

score: 0
Accepted
time: 927ms
memory: 7828kb

input:

50 100 100000 100000
96257 21974
69941 19754
10468 77322
61332 52822
16231 73285
8385 16517
76647 70853
37321 44407
8130 67217
93597 37268
25275 79279
42354 93989
17497 66060
9954 28344
70568 44280
76298 58367
84598 68263
11882 61809
6711 29329
83208 88488
5986 56370
54509 10050
31186 75531
11430 72...

output:

11550590159540
8860005767760
12315316362980
11320250531139
11722115226249
11568253723200
12891842128744
11691686626275
12165483779825
10731100863032
11523369454960
12511572203273
13464219757022
11046689652944
11564814342564
11158806972549
11675195081274
11462012446145
10854048341304
10987852339863
1...

result:

ok 50 lines

Subtask #4:

score: 0
Wrong Answer

Test #37:

score: 12
Accepted
time: 934ms
memory: 7756kb

input:

50 100 100000 1000000000
64674 582989836
17174 628184989
7993 598433899
93758 468751386
36632 620786833
54253 85788398
24335 220088249
41708 370324059
57541 192813008
20125 886362267
3571 180283386
31249 729879131
48870 314235662
40658 954471739
36545 20574741
87835 599485007
44057 459200718
16186 4...

output:

122583343290315160
123180788743136835
106848070437186806
121399598099481552
114671328948865344
109261786979152885
110804547540967368
113454653581765212
115223347014415782
110426946040785506
99271607302919308
106746424290880101
116326704862592262
117403415008037235
111777281124226281
1120538340236074...

result:

ok 50 lines

Test #38:

score: 0
Accepted
time: 938ms
memory: 7704kb

input:

50 100 100000 1000000000
67522 520789926
43607 555188016
12806 26905813
74021 342182108
872 913074774
77839 600895907
98718 947434810
27725 83418280
15106 511494616
87291 653881493
13841 729625677
74682 845713944
43470 585103095
70733 680058976
93952 631790842
81757 406650788
78511 347358907
1462 79...

output:

111520718305066983
111150031374464374
105780424303141838
114502300985346801
115023403779126336
120051990993902080
108860924694174885
124780394360220333
105947234484838092
101750061643019517
103438889113853510
124268485639108728
110280919053980670
109164067626109363
117339974852626500
120296159408922...

result:

ok 50 lines

Test #39:

score: -12
Wrong Answer
time: 931ms
memory: 7780kb

input:

50 100 1000000000 1000000000
425480934 596069354
885929408 208894636
849118145 369603853
32862979 470731422
89195782 993965771
857712104 655472942
199757011 70181666
872007093 442633879
7677494 366180389
233638375 633102946
93301174 365363320
934036650 47362033
585644491 757551572
95389025 322632438...

output:

9222730190735295461
9221534508861223844
9215109395377224874
9217832526221372992
9216971722007756363
9219569022322798037
9220526647669472076
9222278368806529418
9221831966262906961
9216260315852948262
9217262612809008432
9219041794992377984
9215590712382717628
9221031487188526514
9210121298248110860
...

result:

wrong answer 1st lines differ - expected: '1206314604834600491034', found: '9222730190735295461'

Subtask #5:

score: 0
Wrong Answer

Test #49:

score: 0
Wrong Answer
time: 943ms
memory: 7772kb

input:

50 300 100000 1000000000000
21621 667704611522
95538 504360767965
20121 374291791983
58259 527043478787
9507 542834074255
46613 834605157827
59064 675317470117
92489 500884084061
92529 451667545421
21745 407068201316
3514 222491362996
44418 198133054017
8437 358148875035
28745 928794182062
90101 554...

output:

9223287640924269905
9222804735689971120
9223362376154319377
9223254298936815336
9222994380668666218
9223175659523360680
9223303018411509038
9222776370783991424
9222459656996880056
9223102531322382652
9222530117324913806
9223171466748240308
9223334751347424256
9223103841435015936
9223326112089233734
...

result:

wrong answer 1st lines differ - expected: '1024354444153173318804', found: '9223287640924269905'

Subtask #6:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 945ms
memory: 5712kb

input:

50 300 1000000000 1000000000
622938742 803340090
411563373 506291511
661934617 381755435
876890605 94166677
279496763 869423201
508007585 131998848
592251587 47733172
703056185 932460203
228695499 72609615
129679067 589829468
272070690 179647026
185157790 460526572
351519179 920281520
843895312 1023...

output:

9222701438845736585
9222773591345276405
9223170636677374182
9223236757305674499
9221950494609027844
9221760928647101644
9218329891941919424
9220680883344546945
9223172448935388916
9222043916464796536
9223005954249881940
9216979752943317019
9222746798682728432
9222194407605133064
9222916537321274896
...

result:

wrong answer 1st lines differ - expected: '10145178504143463639155', found: '9222701438845736585'

Subtask #7:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 959ms
memory: 5876kb

input:

50 800 100000 1000000000000
98918 860842806148
33478 598362503847
18531 201301091495
53208 640503897011
43307 430663243504
74638 460997604730
14440 749299232168
15540 46909570195
54856 833537407449
70810 868074038174
17982 623720662739
34195 105105463226
76704 538435018409
23449 43950632205
21959 38...

output:

9223304824270911108
9223183783918377338
9222984909367033246
9223086850051151890
9223299714423211039
9223316109732252953
9222492109017751868
9223294613185826960
9223008528399118096
9223167695287646327
9223319133908319024
9223317779509024592
9223052571103460186
9222917605645293620
9223114110530850529
...

result:

wrong answer 1st lines differ - expected: '7370339999554792336414', found: '9223304824270911108'

Subtask #8:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 991ms
memory: 5888kb

input:

50 1500 100000 1000000000000
18757 387292221744
29053 379348011407
47483 314966420174
80638 546097965718
84807 917566638908
59364 705165061774
25136 779704406223
23865 837453418495
38499 811293770591
84972 313037387571
23632 69910257865
36366 901965627066
33323 800225614191
75382 895280109542
95500 ...

output:

9223171928718352508
9223236034697649875
9223227644992976276
9223177318375817156
9221071724210390252
9223246422101059372
9223237553026251593
9223262819227476188
9223331822889445161
9223328994231942540
9223282111603421824
9222334934391793008
9223239098212448713
9223157138751952808
9222981442293761895
...

result:

wrong answer 1st lines differ - expected: '25099931872189852821766', found: '9223171928718352508'

Subtask #9:

score: 0
Wrong Answer

Test #85:

score: 8
Accepted
time: 1044ms
memory: 5828kb

input:

50 2500 10000 1000000000
1989 715660116
726 205696491
906 80983641
1280 135698142
9814 930386766
3162 86759005
1412 262080798
8338 590216389
8436 932386996
9530 971462836
3099 385836418
6344 24362894
4400 361413630
9974 582107128
1025 746910753
2258 921930336
3036 21556198
5903 237088626
9254 502009...

output:

7005218822778586245
6971750534725612064
6954161620845859665
7013134062885514605
7100199492400670100
6776299504139543856
7135284309783918702
6936309620545673088
7068393840281136864
6942766703807986548
6944154377884217714
7029230310347143680
6918324838079558790
6998172166422429400
6798609950334386488
...

result:

ok 50 lines

Test #86:

score: 0
Accepted
time: 1056ms
memory: 5756kb

input:

50 2500 10000 1000000000
1732 653460207
5671 132699518
3015 509455555
1542 449320352
4054 77450515
6748 601866515
7283 989427359
8546 303310611
3297 956101308
6696 884206255
665 230146006
7072 435165003
6296 222215656
49 307694366
8431 208383749
373 434128821
194 909714387
6987 263468142
794 7754762...

output:

6861311554744926930
6868438721666834158
7000938328427297100
6986177933898819838
6946288297434274374
6889294912143244768
6879840522539270224
6955101059714688884
6975882328390193300
6862885747280574304
6955807429667572756
6821641794893341132
7056609081747995400
6924742141404933846
6967566622405516582
...

result:

ok 50 lines

Test #87:

score: -8
Wrong Answer
time: 1022ms
memory: 5680kb

input:

50 2500 100000 1000000000000
64247 516122355312
98364 854165978664
72281 424564939374
50265 845786707126
89743 255262167218
23994 593049450047
75370 432765515137
48323 355394824524
67264 578240134085
65850 163859718473
58217 995936750988
12170 335329048325
90658 928964193417
29667 272420479286
45869...

output:

9223351990210003480
9223243113965658712
9223359716444235560
9223132340718725422
9223252678705482176
9223359270816512602
9223207009880893268
9223358426456824132
9223324275516485052
9222955937880824622
9222541505332456016
9223285565791880748
9223313291745186893
9223354600650753874
9223176034639531438
...

result:

wrong answer 1st lines differ - expected: '69855809501000434363128', found: '9223351990210003480'

Subtask #10:

score: 0
Wrong Answer

Test #93:

score: 0
Wrong Answer
time: 1065ms
memory: 5804kb

input:

50 3000 10000 1000000000
2737 308421419
1673 866261939
7204 148757554
1832 755475073
6111 239582749
5110 227503898
7381 928418391
4831 719415538
4618 750355710
1602 775678323
490 537881445
163 880774777
8544 75938451
2585 496945876
3375 309585347
1089 926499529
7965 908906210
1001 39148177
9619 6401...

output:

9223371931257273600
9223371924311463550
9223371900888899920
9223371995905821336
9223371987147628080
9223371969608072685
9223372033722553828
9223372031170844988
9223371775759629220
9223372020548668581
9223371866672063100
9223372022214889937
9223372007074506775
9223371972246743289
9223371658981826691
...

result:

wrong answer 1st lines differ - expected: '10107755825402443110', found: '9223371931257273600'