QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#62390 | #1864. Might and Magic | lmeowdn | AC ✓ | 619ms | 3652kb | C++17 | 1.1kb | 2022-11-18 17:44:57 | 2022-11-18 17:45:01 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define eb emplace_back
#define fi first
#define se second
#define pc __builtin_popcount
typedef pair<int,int> pii;
typedef vector<int> vi;
long long read() {
long long res=0, w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {res=res*10+c-'0'; c=getchar();}
return res*w;
}
int cp,cm,h0,a1,d1,n,T,ans;
vi pans;
signed main() {
T=read();
while(T--) {
cp=read(), cm=read(), h0=read()-1, a1=read(), d1=read(), n=read();
ans=max(cp*max(1ll,(n-d1)),cm*(n-1));
for(int l=1,r;l<=h0;l=r+1) {
r=h0/(h0/l);
int y=max(1ll,r/cp)*cp;
if(y>r) continue;
int x=h0/l+1, d0=max(0ll,a1-y/cp), m=n-d0;
if(m<0) continue;
//physic
int att=cp*max(1ll,m-d1);
ans=max(ans,att*x);
//magic
int t=(cp+cm*m)/(2*cm), k=m-t;
if(k>x) k=x, t=m-k;
if(t>m) t=m, k=0;
ans=max(ans,cm*k*t+cp*(x-k));
if(k>0) t++, k--;
ans=max(ans,cm*k*t+cp*(x-k));
}
printf("%lld\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3544kb
input:
2 1 1 4 5 1 4 2 5 1 9 9 6
output:
4 25
result:
ok 2 number(s): "4 25"
Test #2:
score: 0
Accepted
time: 7ms
memory: 3544kb
input:
100 1 1000000 1000000 1 1 1000000 1 1 63 17 3 16 5 3 73 3 10 16 5 2 23 20 5 19 5 4 30 16 5 16 1 1 76 14 1 13 374334 265401 231663 11 3 4 204467 215696 313373 10 1 10 457955 456092 253432 17 5 9 643 474603 40411 20 4 7 35009 444310 461190 5 4 11 1 1 142615 53408 206285 486539 1 1 64714 344368 141319 ...
output:
250000000000500000 63 300 70 60 76 796203 1941264 3648736 5695879 10663440 41432081955 144412 295493195 23791 218732 36719904038 102709259153 24982059009 122260194720 318231902520 290946873 222255159 8953678 24315820 372763998 133449680 2945306265 127756463562 176192604 240454816992 242305688722841 ...
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
10 21 212 26101 23 13 1456 131673 859132 20994 30773 24134 2355 84859 973 541 109013 96108 163455 1477 5 9 4407 1 104414 191 5748 1963 66 11232 384 798 114 135 57 52795 180526 444 3550 16574 185 24504 129705 3203 944 4 9318 850981 3286 18039 8 14112 374 679 1 1221 4612 53812 196 1163 1
output:
108997914 2022396728 5714999073 154218001 19474224 101929338 17467256700 3101040 18039 1221
result:
ok 10 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 3432kb
input:
100 53841 5266 18313 59235 11 299778 648 22 578 1 118 6504 1 1 55 33493 3 119206 52985 532083 306 26 153921 132 1 60 67 127590 68852 215208 260 116391 5 10555 89309 3 969929 3596 4202 35 60109 10274 364 1 50736 36 17598 8282 644 274 119 2 6 9 2 68957 338 6 4 34 49 211290 2515 3 13 28894 114825 51501...
output:
16139755047 4138128 4714105 69702873 351959040 232782 36941708 1134980 2192 19928597 316867387200 23240566890 3986100 311343 3014331168 1830033584 410982660 998578 8781670012 66 69697216 848848080 473 15308579223 114 1022552170722 113138358 1600665 6776064 29492122 23377152 12140920 2869334559 39285...
result:
ok 100 numbers
Test #5:
score: 0
Accepted
time: 12ms
memory: 3476kb
input:
1000 31740 161 23 253 39391 116 189260 1572 23918 151265 257 2643 1088 164 1844 11 26836 413618 169 1 330 939983 387 171957 1638 27337 2014 739 1717 3027 30 3836 41640 704 4865 341 7 53279 99843 71 182 13 383459 31 714233 34 183 45 132 69 2304 4811 5841 20 9227 17 15672 55 20 978 152503 45 26 999309...
output:
31740 451574360 841615872 28995330 125039438 3763116 2239083 766918 1311 16682416 152503 35144 929832817 96 1375 19645395 611673 291108285 360819450 606075 119369271426840 55464178582 112174980 16848193 712 57610 266737 157014 23936960 130082203 16297 43538900736 10339373331760 23930048 57130875750 ...
result:
ok 1000 numbers
Test #6:
score: 0
Accepted
time: 98ms
memory: 3552kb
input:
10000 6043 113 60026 976 280620 19846 38551 36157 1 96707 5 5 266 486 678922 3 150 14 15 60 2357 3 492130 1270 17 938 3 4529 33272 128777 899704 4835 7 4 3704 746105 278804 13509 552458 175 14 1 501 2520 21 20 2085 1 542100 586273 389 1 10 1442 137949 112673 140701 210823 4 45065 25 2609 23431 12604...
output:
21312930 144628 694998 10522800 120791888 667941149304 278804 501 844819393 6216119889 127841 214410280 128182286862 10557 123996300 2167728030 19739041272 2473693188 165061764 10005118 6320606430 161602 152400 85023 55132766 260518125 14952388156992 586678 4856832 329488 40089 537179453 153 1299395...
result:
ok 10000 numbers
Test #7:
score: 0
Accepted
time: 378ms
memory: 3652kb
input:
10000 409833 325026 455618 756058 525681 420793 502640 821878 878369 427153 484445 79364 227148 898808 52854 439738 317850 150126 266174 725187 167175 957096 710986 858494 666914 831822 313411 540412 996943 277372 37352 171397 717574 562245 696265 299668 202193 124587 696525 634583 407250 913705 851...
output:
136768340592 65226703714 134933551000 622567963191 230723299962 51362024799 139098395412 1663644970880 10795611354 179729595382 3539190750 917733393225 23406848079 22847515944 254493796370 135844404726 4045577356 1130400474606 208090576074 122738752761 339330528900 126664273176 236324881638 54460252...
result:
ok 10000 numbers
Test #8:
score: 0
Accepted
time: 494ms
memory: 3492kb
input:
10000 1 1 270454 645325 719781 885873 1 1 369312 994801 865474 82254 1 1 695823 387752 55364 286342 1 1 788653 568396 39878 62940 1 1 140875 448675 891104 448114 1 1 433761 295802 463010 692131 1 1 294855 517441 219859 860324 1 1 474291 707814 332651 918042 1 1 316149 481076 889742 430398 1 1 724400...
output:
14466105530 82253 739494 125876 448113 39269602821 36274536375 11049427287 530936 203742 74048384493 10151038504 66556 313512 249130 735405 125583622980 2306059274 4226798222 16625 534189 593940 754390 201630057876 643694 706769748 46734862284 18975 120245918471 20537797927 176352453795 605303 48386...
result:
ok 10000 numbers
Test #9:
score: 0
Accepted
time: 612ms
memory: 3628kb
input:
10000 1 1 823392 1 1 1 1 1 552410 1 1 1 1 1 352676 1 1 1 1 1 772504 1 1 1 1 1 822816 1 1 1 1 1 717266 1 1 1 1 1 414346 1 1 1 1 1 232778 1 1 1 1 1 305038 1 1 1 1 1 593396 1 1 1 1 1 497291 1 1 1 1 1 722489 1 1 1 1 1 704403 1 1 1 1 1 910135 1 1 1 1 1 42925 1 1 1 1 1 505918 1 1 1 1 1 487892 1 1 1 1 1 11...
output:
823392 552410 352676 772504 822816 717266 414346 232778 305038 593396 497291 722489 704403 910135 42925 505918 487892 117267 47414 481966 22008 874045 412591 606113 982951 406063 648670 437166 830664 362909 221002 5356 258945 250496 780666 42354 576377 215950 220085 183894 118233 540287 639810 25252...
result:
ok 10000 numbers
Test #10:
score: 0
Accepted
time: 619ms
memory: 3544kb
input:
10000 1 1 445448 45 53 26 1 1 512580 14 62 59 1 1 792560 19 10 143 1 1 554743 45 38 113 1 1 197423 77 48 11 1 1 630781 31 1 128 1 1 426411 125 64 50 1 1 436423 160 83 138 1 1 701695 129 24 85 1 1 796091 168 81 64 1 1 241914 138 44 62 1 1 911792 194 78 41 1 1 258526 88 57 12 1 1 798579 134 11 53 1 1 ...
output:
23445 513086 91144400 17197033 2992 61185757 5686 150040 331840 7655 31554 5960 3402 250320 1893720 284976 2290 6331570 65579472 291144 28600 3197 6123213 350441 17083 65182 86724 9329140 623 129162 254572 9007 298112 840159 13884416 3833 133834 18832339 56169 52032 546000 674439 363874 8343 1897243...
result:
ok 10000 numbers
Test #11:
score: 0
Accepted
time: 499ms
memory: 3484kb
input:
10000 3 3 1041 525637 127970 446908 4 5 544613 243533 282916 437622 2 4 590379 306427 169219 580118 5 4 668565 556216 210124 58261 3 1 37818 479120 70209 174211 4 1 885833 587854 997910 221730 3 4 683280 483928 824876 979846 3 1 677677 176653 784204 434922 4 3 85971 859293 350311 903509 3 2 528960 9...
output:
1340721 47088816561 74907879746 233040 312006 221729 244303575360 16676138501 1465220796 149082 13807452162 359119779 17096082140 211722 911231 148106 235178699232 300536 134827805952 188123026275 373392 548298 358546699768 140975417520 29572653450 632758 294991307906 465318 137714777940 288654 2010...
result:
ok 10000 numbers
Test #12:
score: 0
Accepted
time: 605ms
memory: 3548kb
input:
10000 44 17 827915 1 1 1 72 93 669644 1 1 1 41 73 366345 1 1 1 77 39 907928 1 1 1 12 74 958892 1 1 1 76 2 884846 1 1 1 29 9 996508 1 1 1 61 18 412834 1 1 1 32 72 739766 1 1 1 83 93 777913 1 1 1 10 80 203468 1 1 1 97 65 298160 1 1 1 18 25 837281 1 1 1 13 25 572916 1 1 1 17 7 630320 1 1 1 59 97 527018...
output:
827948 669672 366376 907984 958896 884868 996527 412848 739776 777959 203470 298178 837288 572923 630326 527047 429617 52974 653938 875655 719780 806936 502384 732165 386890 526284 741925 951126 63584 558752 118530 516945 62651 502320 930450 41650 427680 733278 407284 751608 449124 362280 929890 194...
result:
ok 10000 numbers
Test #13:
score: 0
Accepted
time: 453ms
memory: 3608kb
input:
10000 165 705 222894 86 9 100 743 16 218530 160 30 80 132 770 672784 14 79 49 307 239 609484 140 100 89 307 341 773485 167 27 135 967 28 471431 109 62 106 541 254 306343 61 46 45 345 159 243920 88 89 140 908 770 510708 97 12 20 265 358 595701 146 64 58 802 136 610333 167 91 44 759 745 640155 119 45 ...
output:
1337490 82473 919908 265290 649264 212740 88900 346935 64680 240576 26520 95360 34106842 16766 901068 72594396 436230 834309 511066 31311 26629344 1101144 721824 142950 564480 6547266 549120 173565 199872 7809 11493560 1073462 351013 111012 25020 248310 10959696 318180 23696 18626764 329582 33928680...
result:
ok 10000 numbers
Test #14:
score: 0
Accepted
time: 382ms
memory: 3548kb
input:
10000 290702 1 621544 299643 1 722974 277499 1 81704 210974 1 134735 934604 1 77491 649505 1 594102 451 1 145600 931295 1 379184 193239 1 944719 439419 1 121503 134509 1 897317 419582 1 793340 943389 1 771210 743160 1 254905 672547 1 474240 136853 1 872795 191011 1 503941 722430 1 571158 410082 1 55...
output:
369189505086 37388550266 555249171004 171011533 23478924978 351916703754 240473629656 586994986318 109097269727 203417485362 455986424325 17356624675 88696675280 363449347800 302573422200 272899432260 108818471229 126493065804 247702894621 112285460308 3003200704 501857707200 943128543555 1520980895...
result:
ok 10000 numbers
Test #15:
score: 0
Accepted
time: 609ms
memory: 3548kb
input:
10000 1 828932 256927 1 1 492599 1 354720 718082 1 1 124963 1 384740 446248 1 1 290249 1 467833 476990 1 1 37907 1 554131 509500 1 1 791516 1 929069 888895 1 1 911277 1 702721 310314 1 1 906041 1 828166 38911 1 1 886167 1 178414 432441 1 1 109439 1 538463 379244 1 1 68487 1 400049 591136 1 1 408223 ...
output:
50285869713139028 1384804831969841 8103055501471124 168062064001983 86790432384257626 192880710096556315 129906710461944438 27302627380831856 534211424021242 631411025247197 16666643186904193 1382114361569446 599264933891986 1961571691611345 120534834691872325 33095037477355312 474300943497029 13136...
result:
ok 10000 numbers