QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#426129 | #6693. Fast and Fat | ONISINO | WA | 1ms | 3816kb | C++20 | 1.9kb | 2024-05-30 21:17:44 | 2024-05-30 21:18:59 |
Judging History
answer
#include <bits/stdc++.h>
//DEBUG: https://github.com/sharkdp/dbg-macro
#ifdef LOCAL
#include "../dbg-macro-0.5.1/dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN=2e5+10,MOD=1e9+7,INF=1e9;
ll qpow(ll base,ll exp){ll ans=1;while(exp){if(exp&1)(ans*=base)%=MOD;(base*=base)%=MOD;exp>>=1;}return ans;}
template<class T>ll max_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r+1)/2;if(cmp^!check(m))l=m;else r=m-1;}return l;}
template<class T>ll min_binary_answer(ll l,ll r,T check,bool cmp=true){ll m;while(l<r){m=(l+r)/2;if(cmp^!check(m))r=m;else l=m+1;}return r;}
ll exgcd(ll a,ll b,ll &x,ll &y){ll tmp;return b==0?(x=1,y=0,a):(tmp=exgcd(b,a%b,y,x),y-=(a/b)*x,tmp);}
ll highbit(ll x){for(ll i=1;i<(ll)sizeof(ll)*4;i<<=1)x|=x>>i;return x-(x>>1);}
ll lowbit(ll x){return x&(-x);}
//--------Global declared area--------
//--------Global declared end --------
void solve(int test_num){
int n;
cin>>n;
vector<pair<ll,ll>> a(n+1);
for(int i=1;i<=n;i++){
int v,w;
cin>>v>>w;
a[i]={v,w};
}
sort(a.begin()+1,a.end(),[&](pair<ll,ll>x,pair<ll,ll>y){
if(x.first+x.second==y.second+y.first)
{
if(x.first!=y.first)
return x.first>y.first;
else return x.second<y.second;
}
return x.first+x.second<y.first+y.second;
});
// for(int i=1;i<=n;i++){
// cout<<a[i].first<<' '<<a[i].second<<'\n';
// }
ll ans=1e9;
if(n==1){
cout<<a[n].first;
return;
}else{
if(a[n].second>a[n-1].second){
//cout<<12345;
ans=min(ans,a[n].first);
}else {
//cout<<a[n-1].second-a[n].second<<' ';
ans=min(ans,a[n].first-(a[n-1].second-a[n].second));
}
}
cout<<ans<<'\n';
return;
}
/*
5
1 5
2 4
3 3
5 1
4 2
*/
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr),std::cout.tie(nullptr);
int t=1;
// cin>>t;
for(int i=1;i<=t;i++){
solve(i);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3816kb
input:
2 5 10 5 1 102 10 100 7 4 9 50 2 1 100 10 1
output:
5
result:
wrong answer 1st numbers differ - expected: '8', found: '5'