QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#63752#4233. ResetDaBenZhongXiaSongKuaiDi#WA 2ms5484kbC++14876b2022-11-23 12:07:272022-11-23 12:07:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-23 12:07:29]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5484kb
  • [2022-11-23 12:07:27]
  • 提交

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'