QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619273 | #2442. Welcome Party | WorldFinalEscaped# | WA | 189ms | 10852kb | C++14 | 1.0kb | 2024-10-07 13:43:17 | 2024-10-07 13:43:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define F first
#define S second
pair<ll,ll> a[N];
ll suf[N];
int T,n;
set<ll> s;
bool cmp(pair<ll,ll> a, pair<ll,ll> b){
return a.F<b.F || (a.F==b.F && a.S>b.S);
}
int main(){
for (cin>>T; T; T--){
scanf("%d",&n);
for (int i=1; i<=n; i++) scanf("%lld%lld",&a[i].F,&a[i].S);
sort(a+1,a+1+n,cmp); ll ans=2e18;
for (int i=n; i>=1; i--) suf[i]=max((i==n?0ll:suf[i+1]),a[i].S);
for (int i=1; i<=n; i++){
if (i!=n && suf[i+1]>=a[i].F){ ans=min(ans,suf[i+1]-a[i].F); continue; }
auto it=s.lower_bound(a[i].F);
if (it!=s.end())
ans=min(ans,abs((*it)-a[i].F));
if (it!=s.begin()){
it--;
ans=min(ans,abs(max(suf[i+1],(*it))-a[i].F));
}
s.insert(a[i].S);
}
for (int i=1; i<=n; i++) suf[i]=0;
printf("%lld\n",ans); s.clear();
}
}
/*
1
3
3 5
4 7
6 2
*/
詳細信息
Test #1:
score: 0
Wrong Answer
time: 189ms
memory: 10852kb
input:
66 5 27 46 89 13 55 8 71 86 22 35 3 3 5 4 7 6 2 2 0 1000000000 1000000000 0 2 1000000000 0 0 1000000000 2 1000000000 0 1000000000 0 2 0 1000000000 0 1000000000 2 1000000000 1000000000 0 0 2 0 0 0 0 2 1000000000 1000000000 1000000000 1000000000 3 90 30 90 50 90 85 3 0 0 0 2 0 5 3 20 30 20 50 20 70 3 ...
output:
3 1 0 0 1000000000 1000000000 1000000000 0 0 5 0 10 10 10 3 0 10 5 0 40 0 30 5 10 17 0 10 30 35 146595730144168239 18282751682851787 567456452839834165 375005325495365809 46751451188711820 365292306661444331 23639646046527434 266410634345647121 270663364266559542 309984981384674928 21494649603533736...
result:
wrong answer 13th lines differ - expected: '5', found: '10'