QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#454640 | #7768. Grievous Lady | kkkgjyismine4 | 0 | 449ms | 3940kb | C++23 | 1.1kb | 2024-06-25 08:27:01 | 2024-06-25 08:27:02 |
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;
struct Node{ll a,b;}c[3030];
bool operator<(Node a,Node b){
return ((i28)a.a*(i28)b.b<(i28)a.b*(i28)b.a);
}
int p[3030];
bool cmp(int a,int b){
return c[a].b>c[b].b;
}
bool vis[3030];
void solve(){
ll sa=0,sb=0;
for(int i=1;i<=n;++i)scanf("%lld%lld",&c[i].a,&c[i].b),p[i]=i,vis[i]=0,sa+=c[i].a,sb+=c[i].b;
sort(c+1,c+n+1);i28 ans=0;
sort(p+1,p+n+1,cmp);
for(int i=0;i<=n;++i){
ans=max(ans,(i28)sa*(i28)sb);
ll Sa=sa,Sb=sb;
for(int j=1;j<=n;++j){
if(vis[j])continue;
sa-=c[j].a,sb+=c[j].b;
ans=max(ans,(i28)sa*(i28)sb);
}
sa=Sa,sb=Sb;
if(i<n)vis[p[i+1]]=1,sa-=c[p[i+1]].a,sb+=c[p[i+1]].b;
}
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(){
int t;ll ta,tb;
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: 0ms
memory: 3668kb
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:
3662488830 2332970384 3432123219 2486662417 2457413822 2328658172 3074920464 4149981000 3672306930 3677419620 3099618808 2033355000 2643509790 2798885136 3308845085 2356684512 3476324931 1191604800 3616613391 3698269338 2544923166 1846566741 3828189560 3215168100 2552737062 3521634648 3483121103 235...
result:
wrong answer 1st lines differ - expected: '1356022774', found: '3662488830'
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 1ms
memory: 3664kb
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:
26187284032 26519733060 29236563720 27286747685 24774424317 29815268760 30483140352 21827594596 29307635944 31924114397 33169617360 22980742412 24928280923 26609651537 30864406400 29393997038 30840850050 25334513561 26364823308 34565538050 25074178944 31190756170 34066044912 28875263690 28607595029 ...
result:
wrong answer 1st lines differ - expected: '9075997372', found: '26187284032'
Subtask #3:
score: 0
Wrong Answer
Test #33:
score: 0
Wrong Answer
time: 0ms
memory: 3652kb
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:
267277195689 277112249508 310992663618 258925301920 317892416792 322503306180 293934475188 303313245300 337010154635 344568269121 287549618650 305494467600 316921464275 289294673800 303916565916 309973693728 308413488264 288823215420 278141650980 287642881596 335116750350 290734297308 349740891308 3...
result:
wrong answer 1st lines differ - expected: '99383125432', found: '267277195689'
Subtask #4:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 2ms
memory: 3612kb
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:
335806632373748488 340084638078218880 304568489646806935 331273555508815990 331438981782808336 298760496538160496 305248344962688840 323600615384069153 316446379335030508 301028289436188432 268572675733777016 292638175606395734 325787418624432270 330822742778339275 302339548939004503 304952492389710...
result:
wrong answer 1st lines differ - expected: '122583343290315160', found: '335806632373748488'
Subtask #5:
score: 0
Wrong Answer
Test #49:
score: 0
Wrong Answer
time: 8ms
memory: 3940kb
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:
2875210927802262005636 3063640644237421451338 2630406915877581162063 2658902521611971017500 2956218061685562106000 2679252127489765180808 2904341740167854515245 2668612709648258795970 2783039457778635386793 2471591498969427910735 2711487712279786710336 2649888442563270286090 2637069369112057001850 2...
result:
wrong answer 1st lines differ - expected: '1024354444153173318804', found: '2875210927802262005636'
Subtask #6:
score: 0
Wrong Answer
Test #51:
score: 0
Wrong Answer
time: 8ms
memory: 3624kb
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:
27512868834775617940985 26834652778716541098135 26654719129710682143582 27027447383175636312657 26035399272020377746765 27443063480234954386310 26855814296823574690426 24456583998614209449078 25824957427801713022190 29034081267381518328598 27870327425751501533292 28063515564343448825912 277717573879...
result:
wrong answer 1st lines differ - expected: '10145178504143463639155', found: '27512868834775617940985'
Subtask #7:
score: 0
Wrong Answer
Test #61:
score: 0
Wrong Answer
time: 40ms
memory: 3728kb
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:
20304012046042628572917 18837670770950262120786 20571438988728665742150 20234713159557080575401 19556706896567274046170 18612436550817638601456 20079210848312332495138 18984469557353174932401 19495243902523340672996 20513266231606616840542 19870359288250440162060 20316348358333373832288 199006976150...
result:
wrong answer 1st lines differ - expected: '7370339999554792336414', found: '20304012046042628572917'
Subtask #8:
score: 0
Wrong Answer
Test #73:
score: 0
Wrong Answer
time: 120ms
memory: 3744kb
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:
69119207077832823659208 69720157440434561166120 69966065460047709132194 70154336318570953094412 72190615830894749443970 67759321115741841248961 69444461964396379467328 68818186252674970237818 69705842896304676728110 67888022104662732602934 70454547086381094746940 66924425577800755776310 686000087121...
result:
wrong answer 1st lines differ - expected: '25099931872189852821766', found: '69119207077832823659208'
Subtask #9:
score: 0
Wrong Answer
Test #85:
score: 0
Wrong Answer
time: 312ms
memory: 3720kb
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:
19586792883605160250 19119260166070915920 19247595724664498102 19473932236909522346 19853738091615949870 18870923125300303037 19779054710909923932 19224266936757490344 19458130864919396352 19334039008509303462 19207385516905416468 19532412094014783440 19360618358933376769 19416261634669529600 189615...
result:
wrong answer 1st lines differ - expected: '7005218822778586245', found: '19586792883605160250'
Subtask #10:
score: 0
Wrong Answer
Test #93:
score: 0
Wrong Answer
time: 449ms
memory: 3656kb
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:
28118038927717726638 27958013760319067709 27076938671798060640 28548310305415168482 28383026439060865480 27902002405836188736 27853706482665511484 28064675199116026434 27932396867304338176 27463963334983347725 28099885328859567294 27802997402094665955 27159786577897982967 27551464128867344780 277098...
result:
wrong answer 1st lines differ - expected: '10107755825402443110', found: '28118038927717726638'