QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371418#6693. Fast and Fat1017906723WA 1ms3572kbC++141.1kb2024-03-30 11:10:202024-03-30 11:10:21

Judging History

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

  • [2024-03-30 11:10:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2024-03-30 11:10:20]
  • 提交

answer

#pragma GCC optimize(3,"Ofast","inline")
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll; 
#define int long long
#define ld long double
int n,k;
int sum=0;
int id=0;
struct node{
	int v,w;
}a[100010];
bool operator<(node z,node y){
	return z.v<y.v;
}
vector<int>tz,ty;
bool check(int x){
tz.clear(),ty.clear();
	for(int i=1;i<=n;i++){
		if(a[i].v<x){
			tz.push_back(a[i].w);
		}else{
			int ti=a[i].v-x;
			ti+=a[i].w;
			ty.push_back(ti);
		}
	}
if(tz.size()>ty.size()) return 0;
int zid=tz.size()-1;
int yid=ty.size()-1;
 while(zid>=0){
 	if(tz[zid]>ty[yid]) return 0;
zid--,yid--;
 }
return 1;
	
}
void solve()
{ 
 cin>>n;
 for(int i=1;i<=n;i++){
 	cin>>a[i].v>>a[i].w;
 }
	//sort(a+1,a+1+n);
   int l=1,r=1e17+1;
	while(l<r){
		int mid=(l+r+1)/2;
		if(check(mid)) l=mid;
		else r=mid-1;
	}
cout<<l<<endl;
}

signed main()
{
	ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
	int t; cin>>t;
	while(t--)
{
	solve();
}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3572kb

input:

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

output:

1
1

result:

wrong answer 1st numbers differ - expected: '8', found: '1'