QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#264040 | #6823. Coffee Overdose | vp_account# | TL | 2713ms | 3884kb | C++14 | 1.4kb | 2023-11-25 11:52:36 | 2023-11-25 11:52:36 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int s,c,ans,T;
int read(){
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x*f;
}
int f(int x,int y){
int mid=y+(x-1)*c; if (mid>s) return 0;
return (s+mid+1)*(s-mid)+(c-1)*(y*2+(x-1)*c)*x;
}
signed main(){
T=read();while (T--){
s=read();c=read()+1;ans=0;
/*for (int i=0;i<=(s-1)/c+1;i++)
for (int j=1;j<=s;j++)
ans=max(ans,f(i,j)); */
const int limit=(s-1)/c+1;
for (int i=max(limit-100,0ll);i<=limit;i++){
const int x=f(i,c/2);int cur,last,head=c/2,tail=c/2; ans=max(ans,x);
last=x; while (head>1&&(cur=f(i,head-1))>=last) head--,last=cur,ans=max(ans,cur);
last=x; while (tail<s&&(cur=f(i,tail+1))>=last) tail++,last=cur,ans=max(ans,cur);
last=f(i,s);int now=s;ans=max(ans,last);
while (now>1&&(cur=f(i,now-1))>=last) now--,last=cur,ans=max(ans,cur);
}
for (int i=0;i<=min(100ll,limit);i++){
const int x=f(i,c/2);int cur,last,head=c/2,tail=c/2; ans=max(ans,x);
last=x; while (head>1&&(cur=f(i,head-1))>=last) head--,last=cur,ans=max(ans,cur);
last=x; while (tail<s&&(cur=f(i,tail+1))>=last) tail++,last=cur,ans=max(ans,cur);
last=f(i,s);int now=s;ans=max(ans,last);
while (now>1&&(cur=f(i,now-1))>=last) now--,last=cur,ans=max(ans,cur);
}
printf("%lld\n",ans/2);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3804kb
input:
4 1 2 2 1 10 4 172800 172800
output:
2 3 63 29859840000
result:
ok 4 tokens
Test #2:
score: 0
Accepted
time: 53ms
memory: 3812kb
input:
100000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok 100000 tokens
Test #3:
score: 0
Accepted
time: 233ms
memory: 3732kb
input:
100000 201 1 201 2 201 3 201 4 201 5 201 6 201 7 201 8 201 9 201 10 201 11 201 12 201 13 201 14 201 15 201 16 201 17 201 18 201 19 201 20 201 21 201 22 201 23 201 24 201 25 201 26 201 27 201 28 201 29 201 30 201 31 201 32 201 33 201 34 201 35 201 36 201 37 201 38 201 39 201 40 201 41 201 42 201 43 2...
output:
20301 20302 20304 20309 20316 20328 20343 20365 20391 20426 20466 20517 20574 20644 20721 20813 20913 21030 21156 21301 21435 21588 21735 21837 22001 22152 22248 22359 22533 22680 22785 22848 22974 23154 23310 23436 23532 23598 23634 23801 23985 24150 24295 24420 24525 24610 24675 24720 24745 24901 ...
result:
ok 100000 tokens
Test #4:
score: 0
Accepted
time: 555ms
memory: 3824kb
input:
100000 401 1 401 2 401 3 401 4 401 5 401 6 401 7 401 8 401 9 401 10 401 11 401 12 401 13 401 14 401 15 401 16 401 17 401 18 401 19 401 20 401 21 401 22 401 23 401 24 401 25 401 26 401 27 401 28 401 29 401 30 401 31 401 32 401 33 401 34 401 35 401 36 401 37 401 38 401 39 401 40 401 41 401 42 401 43 4...
output:
80601 80602 80604 80609 80616 80628 80643 80665 80691 80726 80766 80817 80874 80944 81021 81113 81213 81330 81456 81601 81756 81932 82119 82329 82551 82798 83058 83345 83636 83916 84227 84448 84759 85068 85260 85551 85877 86108 86256 86601 86920 87150 87290 87531 87885 88182 88407 88560 88641 89001 ...
result:
ok 100000 tokens
Test #5:
score: 0
Accepted
time: 958ms
memory: 3796kb
input:
100000 601 1 601 2 601 3 601 4 601 5 601 6 601 7 601 8 601 9 601 10 601 11 601 12 601 13 601 14 601 15 601 16 601 17 601 18 601 19 601 20 601 21 601 22 601 23 601 24 601 25 601 26 601 27 601 28 601 29 601 30 601 31 601 32 601 33 601 34 601 35 601 36 601 37 601 38 601 39 601 40 601 41 601 42 601 43 6...
output:
180901 180902 180904 180909 180916 180928 180943 180965 180991 181026 181066 181117 181174 181244 181321 181413 181513 181630 181756 181901 182056 182232 182419 182629 182851 183098 183358 183645 183946 184276 184621 184997 185389 185814 186256 186661 187117 187568 187921 188401 188805 189133 189630...
result:
ok 100000 tokens
Test #6:
score: 0
Accepted
time: 1462ms
memory: 3884kb
input:
100000 801 1 801 2 801 3 801 4 801 5 801 6 801 7 801 8 801 9 801 10 801 11 801 12 801 13 801 14 801 15 801 16 801 17 801 18 801 19 801 20 801 21 801 22 801 23 801 24 801 25 801 26 801 27 801 28 801 29 801 30 801 31 801 32 801 33 801 34 801 35 801 36 801 37 801 38 801 39 801 40 801 41 801 42 801 43 8...
output:
321201 321202 321204 321209 321216 321228 321243 321265 321291 321326 321366 321417 321474 321544 321621 321713 321813 321930 322056 322201 322356 322532 322719 322929 323151 323398 323658 323945 324246 324576 324921 325297 325689 326114 326556 327033 327528 328060 328611 329201 329770 330378 330885...
result:
ok 100000 tokens
Test #7:
score: 0
Accepted
time: 2051ms
memory: 3824kb
input:
100000 1001 1 1001 2 1001 3 1001 4 1001 5 1001 6 1001 7 1001 8 1001 9 1001 10 1001 11 1001 12 1001 13 1001 14 1001 15 1001 16 1001 17 1001 18 1001 19 1001 20 1001 21 1001 22 1001 23 1001 24 1001 25 1001 26 1001 27 1001 28 1001 29 1001 30 1001 31 1001 32 1001 33 1001 34 1001 35 1001 36 1001 37 1001 3...
output:
501501 501502 501504 501509 501516 501528 501543 501565 501591 501626 501666 501717 501774 501844 501921 502013 502113 502230 502356 502501 502656 502832 503019 503229 503451 503698 503958 504245 504546 504876 505221 505597 505989 506414 506856 507333 507828 508360 508911 509501 510111 510762 511434...
result:
ok 100000 tokens
Test #8:
score: 0
Accepted
time: 2713ms
memory: 3724kb
input:
100000 1201 1 1201 2 1201 3 1201 4 1201 5 1201 6 1201 7 1201 8 1201 9 1201 10 1201 11 1201 12 1201 13 1201 14 1201 15 1201 16 1201 17 1201 18 1201 19 1201 20 1201 21 1201 22 1201 23 1201 24 1201 25 1201 26 1201 27 1201 28 1201 29 1201 30 1201 31 1201 32 1201 33 1201 34 1201 35 1201 36 1201 37 1201 3...
output:
721801 721802 721804 721809 721816 721828 721843 721865 721891 721926 721966 722017 722074 722144 722221 722313 722413 722530 722656 722801 722956 723132 723319 723529 723751 723998 724258 724545 724846 725176 725521 725897 726289 726714 727156 727633 728128 728660 729211 729801 730411 731062 731734...
result:
ok 100000 tokens
Test #9:
score: -100
Time Limit Exceeded
input:
100000 1401 1 1401 2 1401 3 1401 4 1401 5 1401 6 1401 7 1401 8 1401 9 1401 10 1401 11 1401 12 1401 13 1401 14 1401 15 1401 16 1401 17 1401 18 1401 19 1401 20 1401 21 1401 22 1401 23 1401 24 1401 25 1401 26 1401 27 1401 28 1401 29 1401 30 1401 31 1401 32 1401 33 1401 34 1401 35 1401 36 1401 37 1401 3...
output:
982101 982102 982104 982109 982116 982128 982143 982165 982191 982226 982266 982317 982374 982444 982521 982613 982713 982830 982956 983101 983256 983432 983619 983829 984051 984298 984558 984845 985146 985476 985821 986197 986589 987014 987456 987933 988428 988960 989511 990101 990711 991362 992034...