QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#373212#7768. Grievous LadyPhysics2123030 609ms3848kbC++171.1kb2024-04-01 10:39:452024-04-01 10:39:45

Judging History

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

  • [2024-04-01 10:39:45]
  • 评测
  • 测评结果:0
  • 用时:609ms
  • 内存:3848kb
  • [2024-04-01 10:39:45]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
  int x=0; char c=getchar();
  while(!isdigit(c))c=getchar();
  while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
  return x;
}
void write(__int128 x){
  if(x>10)write(x/10);
  putchar(x%10+48);
}
main(){
  int t=read(),n=read(),A=read(),B=read(),m=n>>1;
  while(t--){
    vector<int> a(n),b(n),p(n),sa(n),sb(n);
    for(auto &i:a)i=read();
    for(auto &i:b)i=read();
    iota(p.begin(),p.end(),0);
    sort(p.begin(),p.end(),[&](int x,int y){
      return (__int128)a[x]*b[y]<(__int128)a[y]*b[x];
    });
    for(int i=0;i<n;i++){
      sa[i]=(i?sa[i-1]:0)+a[p[i]];
      sb[i]=(i?sb[i-1]:0)+b[p[i]];
    }
    __int128 c=0;
    for(int i=max(m-60,0ll);i<min(m+60,n);i++){
      int l=max(i-6,0ll),r=min(i+6,n-1);
      int cl=(l?sa[l-1]:0),cr=(r<n-1?sb[r+1]:0);
      function<void(int)> dfs=[&](int u){
        if(u==r+1){
          c=max(c,(__int128)cl*cr); return;
        }
        cl+=a[p[u]],dfs(u+1),cl-=a[p[u]];
        cr+=a[p[u]],dfs(u+1),cr-=a[p[u]];
      };
      dfs(l);
    }
    write(c),putchar(10);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 3576kb

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:

3045230298
1595278836
2632127940
1498830648
1764490620
1706938264
2198327460
3037676304
2376905056
2786122668
1757491450
1252378072
1811022450
2094846200
2482851334
1742360820
2579308908
614354292
2829816054
2619814315
1827538024
088712864
2835744900
2204101752
1675672544
2837436415
2641892640
15205...

result:

wrong answer 1st lines differ - expected: '1356022774', found: '3045230298'

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 96ms
memory: 3548kb

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:

20686690800
19860968400
21670681503
20533724295
20036581732
24158329380
24453548712
16750633877
24911262868
24354684396
27275839334
17225118670
18591414803
21428910972
24859084262
24553156230
24105550898
19759559625
19489847914
28122233918
18335997693
23800718140
26955087599
22331430135
23764590299
...

result:

wrong answer 1st lines differ - expected: '9075997372', found: '20686690800'

Subtask #3:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 432ms
memory: 3516kb

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:

208123002024
215447123991
256068366255
210835215743
242384957988
265008167223
234703913876
238828236006
265937932158
285824676852
230527215996
245648556918
249202135250
232247250002
231760402056
243100767726
249670992544
236245911746
219739012155
227338716618
265097295367
237947334807
272749748964
2...

result:

wrong answer 1st lines differ - expected: '99383125432', found: '208123002024'

Subtask #4:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 432ms
memory: 3600kb

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:

682813852274173555404
642558669201058691310
637752934218159733306
646593914351735108384
720834181637985529896
603955833920475170075
682877437498171539552
709061467314012346728
612365030164264251682
588598886262419879550
446598016323509447552
437013677582696678336
715215497451574769906
66496575238927...

result:

wrong answer 1st lines differ - expected: '122583343290315160', found: '682813852274173555404'

Subtask #5:

score: 0
Wrong Answer

Test #49:

score: 0
Wrong Answer
time: 609ms
memory: 3612kb

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:

3242628618877269920950572795
3507403523364416498510741004
3141920287690965006777025618
2725854382870301158494846498
3719262302588301572918344240
3476634725137520747007221454
3014334241014163698195336000
2879489599451602047517270512
3438174824007432084774979900
2946934761563192029411853655
3152445368...

result:

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

Subtask #6:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 578ms
memory: 3608kb

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:

11989837968762845371094
11740515941955483098406
11950417730689620483132
12161599670459923111356
11817049088218090866386
12553116416119485138504
12520231241299098773332
0982537628953356790730
11431674136674358677040
12441938102064021359361
12520144166980527124560
12172678951566911953771
1228561682853...

result:

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

Subtask #7:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 605ms
memory: 3652kb

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:

14898597307664732158548964953
11775199968526941111545958762
12121429049648658220835192800
15677476432919353992472391180
12793012364092292548554320297
12231076251900482441686533714
13421206621335268638014519289
12878888743666121527312816624
14154251780149023315064704128
16603592303273637868600118850
...

result:

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

Subtask #8:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 593ms
memory: 3652kb

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:

37326070748393610088979249348
41766693063687504822605248352
37603246209302053500284992000
41231057301653393577133870048
37764219635411466145259247720
38187143721513459444473850388
39157677312354353935645300159
49701302825616165839101836864
41140586446830065508102157819
34204959020299782140415171700
...

result:

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

Subtask #9:

score: 0
Wrong Answer

Test #85:

score: 0
Wrong Answer
time: 584ms
memory: 3848kb

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:

09235528480019922164000
93727024759410441961918
07187400693843513069807
98710512525014839871200
09103604318688515462468
110298481389705397595488
05053523168393796224081
04566015875034306569465
04102976808346924317217
111781513023012222050210
95956414255798947604815
94721477257545516224341
0375477938...

result:

wrong answer 1st lines differ - expected: '7005218822778586245', found: '09235528480019922164000'

Subtask #10:

score: 0
Wrong Answer

Test #93:

score: 0
Wrong Answer
time: 591ms
memory: 3680kb

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:

149053411581745101987270
151907721175201309138643
144153593980265990720450
137235171492461278321750
146470122132682904088183
142177257725509966870092
155072135997376001249264
157198210457339994745332
147263111720026387275372
136134630194682656305625
144437246498672485167808
143572838534683420052519
...

result:

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