QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#65210 | #4233. Reset | Sorting# | WA | 5ms | 11608kb | C++ | 977b | 2022-11-28 02:27:16 | 2022-11-28 02:27:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n;
ll c;
set<pair<ll,int> >s,ps;
set<pair<ll,int> >dl;
ll dy=0;
ll t[200001],d[200001];
vector<pair<ll,ll> >sex[200001];
pair<ll,ll>a[200001];
ll b[200001];
bool check(ll mid){
ll need=0;
for(int i=1; i<=n ;i++){
if(t[i]<=d[i]*mid);
else{
ll fun=t[i]-d[i]*(mid+1);
need+=1+max(fun,0LL);
}
}
if(need<=c) return true;
else return false;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
cin >> n >> c;
if(c<=n){
for(int i=1; i<=n ;i++){
ll t,d;cin >> t >> d;
b[i]=(t+d-1)/d;
}
sort(b+1,b+n+1);
ll ans=b[n];
ll s=0;
for(int i=1; i<=n ;i++) s+=b[i];
ans=max(ans,(s+c-1)/c);
cout << ans-1 << '\n';
return 0;
}
for(int i=1; i<=n ;i++){
cin >> t[i] >> d[i];
}
ll l=0,r=1e9;
while(l!=r){
ll mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid+1;
}
cout << l << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 11608kb
input:
3 5 17 5 5 2 15 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 5ms
memory: 11464kb
input:
2 1345 1344 1 10 10
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 2ms
memory: 11460kb
input:
1 1000000000 1000000000 1
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 5ms
memory: 9544kb
input:
3 2345 333 1 444 2 555 3
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 11492kb
input:
1 500 1000 2
output:
250
result:
ok single line: '250'
Test #6:
score: 0
Accepted
time: 2ms
memory: 11492kb
input:
1 499 1000 2
output:
250
result:
ok single line: '250'
Test #7:
score: 0
Accepted
time: 2ms
memory: 9456kb
input:
3 2345 3333 5 4444 6 5555 6
output:
646
result:
ok single line: '646'
Test #8:
score: 0
Accepted
time: 3ms
memory: 11580kb
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: 2ms
memory: 11456kb
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: -100
Wrong Answer
time: 2ms
memory: 9476kb
input:
5 4 29 8 30 7 2000 1000 2000 1000 2000 1000
output:
4
result:
wrong answer 1st lines differ - expected: '3', found: '4'