QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#65209#4233. ResetSorting#WA 5ms11596kbC++975b2022-11-28 02:26:112022-11-28 02:26:12

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-28 02:26:12]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:11596kb
  • [2022-11-28 02:26:11]
  • 提交

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);
		}
		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: 0ms
memory: 9496kb

input:

3 5
17 5
5 2
15 4

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 11492kb

input:

2 1345
1344 1
10 10

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 11512kb

input:

1 1000000000
1000000000 1

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 11460kb

input:

3 2345
333 1
444 2
555 3

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 2ms
memory: 11500kb

input:

1 500
1000 2

output:

250

result:

ok single line: '250'

Test #6:

score: 0
Accepted
time: 5ms
memory: 11508kb

input:

1 499
1000 2

output:

250

result:

ok single line: '250'

Test #7:

score: 0
Accepted
time: 1ms
memory: 11596kb

input:

3 2345
3333 5
4444 6
5555 6

output:

646

result:

ok single line: '646'

Test #8:

score: -100
Wrong Answer
time: 2ms
memory: 11576kb

input:

8 6
40 10
40 10
40 10
40 10
40 10
20 5
4 3
5 3

output:

48

result:

wrong answer 1st lines differ - expected: '4', found: '48'