QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371417 | #6693. Fast and Fat | 1017906723 | WA | 23ms | 3628kb | C++14 | 1.1kb | 2024-03-30 11:09:19 | 2024-03-30 11:09:20 |
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=1e9+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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3564kb
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: 23ms
memory: 3628kb
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 330752033 261929431 306317965 960871619 691253609 368155842 136979645 142793929 294773918 545696041 230215712 315900406 106941480 412319885 697588906 631916852 300930080 7879527 397420315 43252518 228074208 222727028 707870587 48419546 457987604 377112364 447390353 696516804 3880...
result:
wrong answer 3rd numbers differ - expected: '470297536', found: '330752033'