QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#339669 | #7768. Grievous Lady | cinccout | 0 | 21ms | 4028kb | C++14 | 1.7kb | 2024-02-27 19:32:44 | 2024-02-27 19:32:44 |
Judging History
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.9765,eps=1e-8;
long long suma,sumb;__int128 ans,C;
int c[3005],n;
void mnth(double T)
{
while(T>eps)
{
int x=ran(1,n);
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'+(int)x%10);}
int main()
{
int tim,A,B;cin>>tim;
cin>>n>>A>>B;C=((__int128)n*A*n*B/4);
while(tim--)
{
long long sb=0;int id=0;
for(int i=1;i<=n;i++) a[i].a=read();
for(int i=1;i<=n;i++) 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<=5;i++) mnth(1);
print(ans);puts("");
}
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: 3ms
memory: 3992kb
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:
1215737276 482965362 942693024 220027136 736791488 345438630 534997696 1402038912 983634843 970945500 523989708 503981104 270063761 496573914 914122254 243748725 457817283 271936890 489573860 658604604 406992131 292087950 1097864566 495647468 292668948 690148240 755219573 728350788 550585455 9396033...
result:
wrong answer 1st lines differ - expected: '1356022774', found: '1215737276'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 4ms
memory: 3860kb
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:
9594191682 6246687700 661545372' 720822280. 654135687( 5968233979 799311474. 3869443560 5793022654 9107516644 704300247+ 361288620* 735018724. 767071860. 808897031. 1139074975- 9669583718 819374047- 291319350* 776690174. 4561852704 5183498819 9212454858 5915682548 6083646071 822130746( 751642612) 61...
result:
wrong answer 1st lines differ - expected: '9075997372', found: '9594191682'
Subtask #3:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 7ms
memory: 3792kb
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:
10272602045' 704628290.2 9289092214. 61955978966 4602895664( 5116973091. 44250844906 4966092312( 44926537028 56598750042 35959214306 842300619/0 372555726), 720516248)) 732679138+9 771487552.( 8115627860' 346089683/2 62046697758 706373067*0 747126330)4 295951761'/ 8864249003/ 832973610.4 246930092*....
result:
wrong answer 1st lines differ - expected: '99383125432', found: '10272602045''
Subtask #4:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 8ms
memory: 3772kb
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:
281916053'./2+0/*4700 129091390364++755/240 1211225718-69420(8*0. 1083529843,91*/.-5+-( 1216289890*02)))-/926 9391494983/('7(.7460 1172175253'1'0,850)8. 1211889112(21-4'74**0 10535077814+0+(,*1(.+ 102969629920/26*+48/( 792737252/5-+0*67,-4 851838612*+1135912,9 137656001766(8-2*9(95 10445651777334++....
result:
wrong answer 1st lines differ - expected: '122583343290315160', found: '281916053'./2+0/*4700'
Subtask #5:
score: 0
Wrong Answer
Test #49:
score: 0
Wrong Answer
time: 9ms
memory: 3748kb
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:
2621922300557/2*+*574.-'..** 1125948264*48+-1/,6-6077'544 9338535798/10/-4+*006))+(04 87434702378'03,*04'507-,40- 12013795520+/3.')0'.19247250 963772724517*(.72/0'8*1339- 1120976715-8(0,,148992(')26, 92149767765).4*009/0,8)0,20 9303310011/*3'((/)7(,.,/170 813511683+/62270(+64,0/4,-/ 9378896228+0.*41...
result:
wrong answer 1st lines differ - expected: '1024354444153173318804', found: '2621922300557/2*+*574.-'..**'
Subtask #6:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 6ms
memory: 3748kb
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:
91481149234(',77.,01(- 5886290107)9(0/0090.50 618828086470'6762*./*6 61825638183/7(6770324* 254789368-(244-+404',4 618830291339-1**)3+2-( 238780330-.)0,2.+03.7- 278536884050.9.4402.10 57786010202*98/5/(824) 289907075,(2*-3.2*3,)0 700149308.338,0597+..8 6367610610/60'2*',3/04 322240733+(930.0'9486/ 5...
result:
wrong answer 1st lines differ - expected: '10145178504143463639155', found: '91481149234(',77.,01(-'
Subtask #7:
score: 0
Wrong Answer
Test #61:
score: 0
Wrong Answer
time: 12ms
memory: 3720kb
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:
180917199414058+'()(.'701(980 5907260107)(9*53,67,,/7500+, 6417877391/92,/(100+89040690 73380891302/03452.0.*,0(-.)7 665750148).70053)+*-0,951312 685017204,09-2*(+/1507089*,4 654567978/50824/7'-/8)48320) 675992433'/5)4).75,2'0-,2*/. 670998131--58+/60/0*81+),4.4 740595607(52545,6'),-35/4+22 704093663...
result:
wrong answer 1st lines differ - expected: '7370339999554792336414', found: '180917199414058+'()(.'701(980'
Subtask #8:
score: 0
Wrong Answer
Test #73:
score: 0
Wrong Answer
time: 15ms
memory: 3808kb
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:
5799969390'0582-8//,31)6-3+4) 274888715(0860(8+-9.6..18'8(- 227066370,0)+*25.96+9-292'0+1 251356738-/'96/+18..7*4,5,)0. 236797632),933,0.3+2*)2/).'-* 215640813+695-')-1707/7379(9, 239624278+)()2+'7)2-.)630452/ 245916612))7)''783*/,')81'644 253069652-.,585'7874.(2,96706 215760047*489,--1)3*+0*7-0'6. ...
result:
wrong answer 1st lines differ - expected: '25099931872189852821766', found: '5799969390'0582-8//,31)6-3+4)'
Subtask #9:
score: 0
Wrong Answer
Test #85:
score: 0
Wrong Answer
time: 18ms
memory: 4028kb
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:
1421513172230.100-'66862 792922673,3+6'*-,082970 668462966+*(6-/.1/)+70+ 6425549644/.9(8(++-46.8 666211368/)321678/-'472 6005039866'/6-'9((7--20 6339267158.+-*,0/8,'9'0 63365423120086682.0'4,0 615886295559)(716-4+4*6 648353243*1/()/8169(558 627084344009122/6'./.)- 61264146682'66(2'0)/0., 655694876,3...
result:
wrong answer 1st lines differ - expected: '7005218822778586245', found: '1421513172230.100-'66862'
Subtask #10:
score: 0
Wrong Answer
Test #93:
score: 0
Wrong Answer
time: 21ms
memory: 3792kb
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:
18687843076+9186.26*09.1 1198752617),30-38266816- 95881138937676.(4,-1932 94769369483*+15130(5,80 8859309399'5)8('7*350'0 869595398010-.6/'2+1630 88013442317-440/15-*'-/ 877050447503818559(-)80 9358607486')(*3/7*220/6 855891275/.7*/.8+0+.1.- 8872243732(-*6735,13'-3 848704085,/(5443-,/06,8 8202837950...
result:
wrong answer 1st lines differ - expected: '10107755825402443110', found: '18687843076+9186.26*09.1'