QOJ.ac
QOJ
ID | Submission ID | Problem | Hacker | Owner | Result | Submit time | Judge time |
---|---|---|---|---|---|---|---|
#589 | #375854 | #6823. Coffee Overdose | waretle | Tx_Lcy | Success! | 2024-04-08 20:49:32 | 2024-04-08 20:49:33 |
Details
Extra Test:
Time Limit Exceeded
input:
100000 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 172800 1 17280...
output:
14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 14930006400 ...
result:
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#375854 | #6823. Coffee Overdose | Tx_Lcy | TL | 433ms | 4028kb | C++14 | 806b | 2024-04-03 16:32:38 | 2024-04-08 20:50:04 |
answer
//A tree without skin will surely die.
//A man without face will be alive.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define all(x) (x).begin(),(x).end()
#define rep(i,j,k) for (int i=j;i<=k;++i)
#define per(i,j,k) for (int i=j;i>=k;--i)
int S,C,ans1,ans2;
inline void solve(){
cin>>S>>C,ans1=ans2=0;
int wz=(S+C)/(C+1);
{
ans1=C*(S+S-(C+1)*(wz-1))*wz/2;
//一开始就喝咖啡
}
{
rep(k,0,S/C)
ans2=max(ans2,C*(C-1)/2*k-C*(k-1)*k/2+(S+1)*S/2);
//一开始没喝咖啡
}
cout<<max(ans1,ans2)<<'\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t=1;
cin>>t;
while (t--) solve();
cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<" s\n";
return 0;
}