QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619248 | #2442. Welcome Party | WorldFinalEscaped# | WA | 313ms | 10916kb | C++14 | 963b | 2024-10-07 13:38:53 | 2024-10-07 13:38:54 |
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;
multiset<ll> 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); 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 (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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 313ms
memory: 10916kb
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 0 1000000000 0 0 5 0 50 35 45 38 35 25 5 0 40 0 30 5 10 17 0 10 30 35 146595730144168239 18282751682851787 567456452839834165 375005325495365809 46751451188711820 365292306661444331 23639646046527434 266410634345647121 270663364266559542 309984981384674928 21494649603533736 100200...
result:
wrong answer 6th lines differ - expected: '1000000000', found: '0'