QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#340046#7768. Grievous Ladycinccout0 162ms3880kbC++141.9kb2024-02-28 13:32:052024-02-28 13:32:05

Judging History

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

  • [2024-02-28 13:32:05]
  • 评测
  • 测评结果:0
  • 用时:162ms
  • 内存:3880kb
  • [2024-02-28 13:32:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
    long long x=0,flag=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flag=-flag;ch=getchar();}
    while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
    return flag*x;
}
const int b=RAND_MAX;
struct jgt{long long a,b;}a[3005];
bool cmp(jgt x,jgt y){return x.a-x.b<y.a-y.b;}
int ran(int l,int r){return rand()%(r-l+1)+1;}
const double del=0.978,eps=1e-8;
long long suma,sumb;__int128 ans;
int c[3005],n;double C;int num;
void mnth(double T)
{
    while(T>eps)
    {
        int x=ran(1,n);num++;
        if(c[x]) c[x]=0,suma-=a[x].a,sumb+=a[x].b;
        else c[x]=1,suma+=a[x].a,sumb-=a[x].b;
        __int128 now=(__int128)suma*sumb;
        if(now>ans) ans=now;
        else
        {
            double tmp=exp(1.0*(now-ans)/C/T);
            if(rand()>1.0*tmp*b)
            {
                if(c[x])
                c[x]=0,suma-=a[x].a,sumb+=a[x].b;
                else c[x]=1,suma+=a[x].a,sumb-=a[x].b;
            }
        }
        T*=del;
    }
}
void print(__int128 x)
{if(!x) return;print(x/10);putchar('0'+x%10);}
int main()
{
    //freopen("1.in","r",stdin);
    //freopen("1.out","w",stdout);
    int tim,A,B;cin>>tim;
    cin>>n>>A>>B;C=1.0*((__int128)n*A*n*B)/300;
    while(tim--)
    {
        long long sb=0;int id=0;
        for(int i=1;i<=n;i++)
        a[i].a=read(),a[i].b=read(),sb+=a[i].b;
        sort(a+1,a+n+1,cmp);
        suma=0,sumb=0;ans=0;
        for(int i=1;i<=n;i++)
        {
            suma+=a[i].a;sumb+=a[i].b;
            if((__int128)suma*(sb-sumb)>ans)
            ans=(__int128)suma*(sb-sumb),id=i;
        }
        suma=0;sumb=sb;
        for(int i=1;i<=id;i++)
        c[i]=1,suma+=a[i].a,sumb-=a[i].b;
        for(int i=1;i<=100;i++) mnth(1);
        print(ans);puts("");
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 121ms
memory: 3744kb

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
409720620
571495392
241573944
311542560
390743430
489635410
844700428
405839715
490101850
290469875
342429048
362254844
417139330
589182298
385434300
553639527
149260017
529871360
653866983
398173380
306431296
741546036
478986288
454817703
585977964
428349141
343825026
374578848
648616384...

result:

wrong answer 2nd lines differ - expected: '902566854', found: '409720620'

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 123ms
memory: 3740kb

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
4355974161
3857873691
4031959968
3989031464
4839026399
5262645628
4095922085
5919464430
5165376840
6044505222
2675866278
4489449168
5494420356
5727534141
5862288432
5702547232
4757737944
3032196255
7074420196
4211831328
4862018410
4072893150
4220655840
4614795558
4582289140
3387086248
443...

result:

wrong answer 2nd lines differ - expected: '9741088812', found: '4355974161'

Subtask #3:

score: 0
Wrong Answer

Test #33:

score: 0
Wrong Answer
time: 122ms
memory: 3784kb

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
47056917131
53921086080
41287103488
24978729792
74712541380
50633727044
50742590238
51821286010
57989837640
55424957658
53614151476
56164997906
50205727179
49471374744
52377063480
29171625210
55200336030
46802333472
24159448720
77207783520
50792537330
64789375994
52819402044
50209391580
...

result:

wrong answer 2nd lines differ - expected: '104811638659', found: '47056917131'

Subtask #4:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 128ms
memory: 3828kb

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
76332223361269568
71712393551008212
46420723629605910
89785810475847645
74746582130456865
72958639855582504
89040410128815607
78008462388123498
64774428195806672
59715603929007810
39751521055858161
90062158119228877
77862263932689174
64996012728715080
77631412265324970
77519941854...

result:

wrong answer 2nd lines differ - expected: '123180788743136835', found: '76332223361269568'

Subtask #5:

score: 0
Wrong Answer

Test #49:

score: 0
Wrong Answer
time: 131ms
memory: 3736kb

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:

1024354444153173318804
666585447471571197180
548230609723423359291
504921324995992918026
583441871337250263172
545286914039246580720
577262291466635342100
515247717920992051556
611961149747575129236
541364765997350472544
569226504322485855719
501142850406602737236
544381737191955860289
5246358311470...

result:

wrong answer 2nd lines differ - expected: '1090081056519177596568', found: '666585447471571197180'

Subtask #6:

score: 0
Wrong Answer

Test #51:

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

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:

9549759698713999782700
4686140658722388730007
4875059264683006632492
4301114099460904303368
2656449077080040088246
5470491844197580829732
2524990509361990800900
2205057418005233288742
6309090711634889453940
5315905775400531839426
2537272470257815103373
3014630201380528621000
6181782439365228433188
4...

result:

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

Subtask #7:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 162ms
memory: 3844kb

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:

7370339999554792336414
4253671885765992900950
3879178020121743333646
4226438530218044130300
4007836629536768480760
3744864919313975482880
4171871411261881456756
3883439620635895892229
3771001233419504740505
4161657193904489786374
4063652026014874210390
4123263059414520259000
4148920244173381761048
3...

result:

wrong answer 2nd lines differ - expected: '6862669553866135073811', found: '4253671885765992900950'

Subtask #8:

score: 0
Wrong Answer

Test #73:

score: 0
Wrong Answer
time: 155ms
memory: 3788kb

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:

25098733453072527218464
15486789107508784127871
14953311062769925443195
14568191196649805626752
14497142475801743195008
13630726702679759743904
14163260939019272388018
14623763178077082099246
15178349625750235311413
13316017362986910495132
13740379859205334922752
13124756314096048768493
138599143494...

result:

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

Subtask #9:

score: 0
Wrong Answer

Test #85:

score: 0
Wrong Answer
time: 138ms
memory: 3880kb

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:

4832625551319987751
2850954881786407781
2376468907796692276
2996642043136641859
3092597096090026782
2372078430538678313
2429817782552503416
2915923418998909470
2929603592917089270
2395616488630389272
2941093038946783416
2941878170105513548
3042830087330272600
2354487050429977746
2903756186608697164
...

result:

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

Subtask #10:

score: 0
Wrong Answer

Test #93:

score: 0
Wrong Answer
time: 140ms
memory: 3880kb

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:

6466308874620193440
4222185437896790085
4670738322153494304
4201075786009625072
4231948187154391750
4031361181228252806
4029738742084176520
3980699679970238184
4092029972187398748
4033733078412290493
4084205424785378502
4096528022482234740
3952024982135201470
3938095582967345844
4145279759881973152
...

result:

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