QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371418 | #6693. Fast and Fat | 1017906723 | WA | 1ms | 3572kb | C++14 | 1.1kb | 2024-03-30 11:10:20 | 2024-03-30 11:10:21 |
Judging History
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'