QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#370455 | #4233. Reset | InfinityNS | WA | 42ms | 9668kb | C++20 | 932b | 2024-03-29 08:11:55 | 2024-03-29 08:11:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll lim=1e18;
const ll inf=1e18;
const int N=200050;
ll used[N];
int main(){
int n,c;
scanf("%i %i",&n,&c);
vector<array<ll,3>> take;
ll sum=0;
for(int i=1;i<=n;i++){
int t,d;
scanf("%i %i",&t,&d);
sum+=t;
take.pb({d,t/d,i});
if(t%d!=0){
take.pb({t%d,1,i});
}
}
sort(take.rbegin(),take.rend());
ll top=lim,bot=0,ans;
while(top>=bot){
ll mid=top+bot>>1;
for(int i=1;i<=n;i++)used[i]=0;
ll now=sum;
ll canUse;
if(inf/c<mid+1)canUse=inf;
else canUse=(mid+1)*c;
for(auto p:take){
ll can=min({mid+1-used[p[2]],p[1],canUse});
now-=can*p[0];
canUse-=can;
used[p[2]]+=can;
}
ll left=c;
for(int i=1;i<=n;i++)if(used[i]==mid+1)left--;
if(left>=now){
ans=mid;
top=mid-1;
}else{
bot=mid+1;
}
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
3 5 17 5 5 2 15 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
2 1345 1344 1 10 10
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
1 1000000000 1000000000 1
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4052kb
input:
3 2345 333 1 444 2 555 3
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
1 500 1000 2
output:
250
result:
ok single line: '250'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
1 499 1000 2
output:
250
result:
ok single line: '250'
Test #7:
score: 0
Accepted
time: 0ms
memory: 4024kb
input:
3 2345 3333 5 4444 6 5555 6
output:
646
result:
ok single line: '646'
Test #8:
score: 0
Accepted
time: 0ms
memory: 4068kb
input:
8 6 40 10 40 10 40 10 40 10 40 10 20 5 4 3 5 3
output:
4
result:
ok single line: '4'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
8 6 40 10 40 10 40 10 40 10 40 10 20 5 7 3 5 3
output:
4
result:
ok single line: '4'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
5 4 29 8 30 7 2000 1000 2000 1000 2000 1000
output:
3
result:
ok single line: '3'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
27 19 21 5 14 5 14 5 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000
output:
4
result:
ok single line: '4'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
24 21 25 8 13 7 13 7 13 7 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000 3000 1000
output:
3
result:
ok single line: '3'
Test #13:
score: 0
Accepted
time: 1ms
memory: 4024kb
input:
4 2 10 10 10 10 10 10 9 2
output:
3
result:
ok single line: '3'
Test #14:
score: 0
Accepted
time: 38ms
memory: 7384kb
input:
110000 60000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 100000 222200000 10000...
output:
99999
result:
ok single line: '99999'
Test #15:
score: -100
Wrong Answer
time: 42ms
memory: 9668kb
input:
200000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 10000...
output:
199999999999998
result:
wrong answer 1st lines differ - expected: '199999999999999', found: '199999999999998'