QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#63752 | #4233. Reset | DaBenZhongXiaSongKuaiDi# | WA | 2ms | 5484kb | C++14 | 876b | 2022-11-23 12:07:27 | 2022-11-23 12:07:29 |
Judging History
answer
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define db double
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define int long long
using namespace std;
const int maxn=2e5;
int n,c,t[maxn+5],d[maxn+5];
int check(int mid) {
int cnt1=0,cnt2=0;
for (int i=1;i<=n;i++) {
int x=(t[i]+d[i]-1)/d[i];
if (x<mid) {
cnt1+=x;
} else if (x==mid) {
cnt1+=x;
cnt2++;
} else {
int lst=t[i]-mid*d[i];
cnt1+=mid+lst;
cnt2+=lst+1;
}
if (cnt2>c) return 0;
if (cnt1>mid*c) return 0;
}
return 1;
}
signed main() {
scanf("%lld %lld",&n,&c);
for (int i=1;i<=n;i++) scanf("%lld %lld",&t[i],&d[i]);
int l=1,r=2e14,ans=0;
while (l<=r) {
int mid=(l+r)>>1;
if (check(mid)) ans=mid,r=mid-1;
else l=mid+1;
}
cout<<ans-1;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 5452kb
input:
3 5 17 5 5 2 15 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3524kb
input:
2 1345 1344 1 10 10
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 5484kb
input:
1 1000000000 1000000000 1
output:
86404549241256
result:
wrong answer 1st lines differ - expected: '0', found: '86404549241256'