QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#675992#6693. Fast and FatAnon_chan#WA 37ms5748kbC++20889b2024-10-25 19:53:452024-10-25 19:53:46

Judging History

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

  • [2024-10-25 19:53:46]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:5748kb
  • [2024-10-25 19:53:45]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
const ll N=2e5+10;
ll n;
struct node{
	ll v,w;
}a[N],s[N];
bool cmp(node&a,node&b){
	if(a.v==b.v)return a.w<b.w;
	return a.v<b.v;
}
bool check(ll mid){
	for(int i=1;i<=n;i++){
		s[i]=a[i];
	}
	sort(s+1,s+n+1,[&](node a,node b){
		return max(a.v,mid)+a.w<max(b.v,mid)+b.w;
	});
	int sum=0;
	for(int i=n;i>=1;i--){
		if(s[i].v<mid){
			sum--;
			if(sum<0) return 0;
		}
		else sum++;
	}
	return 1;
}
void solve(){
	cin>>n;
	for(ll i=1;i<=n;++i){
		cin>>a[i].v>>a[i].w;
	}
	sort(a+1,a+1+n,cmp);
	ll l=a[1].v,r=a[n].v;
	while(l<=r){
		ll mid=l+r>>1;
		if(check(mid))l=mid+1;
		else r=mid-1;
	}
	cout<<l-1<<endl;





}
signed main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	ll Time=1;
	cin>>Time;
	while(Time--)solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5696kb

input:

2
5
10 5
1 102
10 100
7 4
9 50
2
1 100
10 1

output:

8
1

result:

ok 2 number(s): "8 1"

Test #2:

score: -100
Wrong Answer
time: 37ms
memory: 5748kb

input:

10000
4
280251502 664541723
375808746 641141991
95134537 898607509
455259328 944978891
2
798417052 547329847
785434740 991778535
6
623628702 857611223
275667427 453747403
292209526 283132767
330752033 988721243
470297536 608192332
477186035 325224271
3
280572174 994054447
306566740 923535026
3781360...

output:

352409014
785434740
470297536
280572174
704877362
960871619
691253609
560579095
136979645
399988835
610497257
576427565
636500913
315900406
370430730
526259135
781258283
631916852
300930080
419999540
431930706
479323438
530080165
391912906
708925499
467782812
457987604
389750718
447390353
696516804
...

result:

wrong answer 42nd numbers differ - expected: '280239022', found: '280239021'