QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454646 | #7768. Grievous Lady | kkkgjyismine4 | 0 | 1886ms | 4196kb | C++23 | 1.3kb | 2024-06-25 08:33:29 | 2024-06-25 08:33:30 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define i28 __int128
#define pii pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
int n;ll a[3030],b[3030];
vector<pii>vec,v1,v2;
int ps[6030],tt;
mt19937 rnd(time(0));
void solve(){
vec.clear(),vec.pb(mp(0,0));
ll s=0;
for(int i=1;i<=n;++i){
scanf("%lld%lld",&a[i],&b[i]),s+=a[i],v1=vec,v2.clear();
for(auto v:vec)v2.pb(mp(v.fi+b[i],v.se+a[i]));vec.clear();
int p=0,q=0;
while(p<v1.size()&&q<v2.size()){
if(v1[p]<v2[q])vec.pb(v1[p++]);
else vec.pb(v2[q++]);
}
while(p<v1.size())vec.pb(v1[p++]);
while(q<v2.size())vec.pb(v2[q++]);
ll mx=-1e18;
v1.clear();
for(auto v:vec){
if(v.se<=mx)continue;
mx=v.se,v1.pb(v);
}
vec=v1;tt=vec.size();
for(int j=1;j<=tt;++j)ps[j]=j;
shuffle(ps+1,ps+tt+1,rnd);
if(tt>3000){
v1.clear();
for(int j=1;j<=3000;++j)v1.pb(vec[ps[j]-1]);
vec=v1;
}
}
i28 ans=0;
for(auto v:vec)ans=max(ans,(i28)v.fi*(i28)(s-v.se));
stack<char>stk;while(stk.size())stk.pop();
while(ans)stk.push((char)(ans%(i28)(10)+'0')),ans/=(i28)(10);
while(stk.size())putchar(stk.top()),stk.pop();
puts("");
}
int main(){
ll ta,tb;
int t;cin>>t>>n>>ta>>tb;
while(t--)solve();
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: 1ms
memory: 3800kb
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:
362499186 198314667 479260704 147091320 281453150 259200592 409315254 724031553 347301990 401359352 210699819 136994895 293887287 414783050 415841832 255496650 392978580 53195320 454728816 557123632 274447432 154043106 601466595 405526534 324771024 495432240 329726043 322043360 387310802 687866760 2...
result:
wrong answer 1st lines differ - expected: '1356022774', found: '362499186'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 3ms
memory: 3828kb
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:
2631446125 2215914535 2603771525 2166958720 2379648219 2900638418 3370170080 1890526635 3723439376 2875351886 4566787845 1730657948 1859634405 2876250758 3074426103 4142475012 2955481698 2454059498 1919496616 4270671164 2045792278 2644266196 3296843482 2871694764 3352769496 2967080432 1966831294 258...
result:
wrong answer 1st lines differ - expected: '9075997372', found: '2631446125'
Subtask #3:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 85ms
memory: 3936kb
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:
20833061688 20593152000 29336937032 23818979064 24143324986 34450840739 26585533952 25823450576 28179306862 36644220170 24344289970 28460017992 28428244410 26014994500 23573964183 26762349054 29238117777 28707759948 22631358314 24244907752 28427019040 27034837452 29523179166 35023211347 23844465632 ...
result:
wrong answer 1st lines differ - expected: '99383125432', found: '20833061688'
Subtask #4:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 82ms
memory: 4196kb
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:
30811007723410530 29858639834666841 29241309964915524 28682016911480250 35466908499781176 27265361069403880 27148129665861868 32721387133009536 25766555147603499 26303169801939213 23820770289077424 29313700976837354 30413593092408030 32018175610686720 26172118574792484 24848794260013086 306166722318...
result:
wrong answer 1st lines differ - expected: '122583343290315160', found: '30811007723410530'
Subtask #5:
score: 0
Wrong Answer
Test #49:
score: 0
Wrong Answer
time: 354ms
memory: 3852kb
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:
319161380635906796332 389133970750827953706 383900397270071097495 334211322146972833840 417812822874998176595 314414645698653796251 345335601503774676654 65208787282285764422 281675870616431183348 290843976396372064000 256065472930620429832 356350428186857273160 373053238747872705792 325978547713569...
result:
wrong answer 1st lines differ - expected: '1024354444153173318804', found: '319161380635906796332'
Subtask #6:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 356ms
memory: 3820kb
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:
2934961416959850477731 2617399720458252553206 1567847144411896133178 2582645400912475874578 3861325479812409121800 2876000328665081016553 2820923239886909582848 2454739313474700182070 3113098214390763407760 3395035170840590079338 3695339061591048780642 4042994512508740189632 2747235988979751877609 3...
result:
wrong answer 1st lines differ - expected: '10145178504143463639155', found: '2934961416959850477731'
Subtask #7:
score: 0
Wrong Answer
Test #61:
score: 0
Wrong Answer
time: 998ms
memory: 3864kb
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:
2191238224470674036316 1882470499718507180746 1608078911685077670300 1696301525139147525060 1266537864095052563616 1847032855622470884460 1892916874064528530225 1157190861726391947381 1992467304733943105961 628060873773270682107 1253783163072603432932 2260842632727119846358 2069809628784424432830 18...
result:
wrong answer 1st lines differ - expected: '7370339999554792336414', found: '2191238224470674036316'
Subtask #8:
score: 0
Wrong Answer
Test #73:
score: 0
Wrong Answer
time: 1886ms
memory: 3960kb
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:
3934773658673267225278 4070039974849280299216 3899381548786079718880 4062080017651684353600 3271591994855562828395 3176482067423276143353 4481031989100175528175 1068099573482788776804 2796641091554271764914 3815143577423363369712 4949344480523834341606 3083843751541230836483 4227639234165065530825 4...
result:
wrong answer 1st lines differ - expected: '25099931872189852821766', found: '3934773658673267225278'
Subtask #9:
score: 0
Time Limit Exceeded
Test #85:
score: 0
Time Limit Exceeded
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:
result:
Subtask #10:
score: 0
Time Limit Exceeded
Test #93:
score: 0
Time Limit Exceeded
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...