QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619156 | #2442. Welcome Party | Lavender_Field# | WA | 177ms | 7580kb | C++20 | 1.6kb | 2024-10-07 13:19:23 | 2024-10-07 13:19:23 |
Judging History
answer
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
typedef long long ll;
using namespace std;
inline int rd() {
int r = 0; bool w = false; char ch = getchar();
while( ch < '0' || ch > '9' ) w = !(ch^45), ch = getchar();
while( ch >= '0' && ch <= '9' ) r = (r<<1) + (r<<3) + (ch^48), ch = getchar();
return w ? -r : r;
}
#define MAXN 100000
const ll INF = 1e18+1;
int n;
struct node {
ll a, b;
}r[MAXN+5];
bool cmp(node x , node y) {
return x.a < y.a;
}
ll rmax[MAXN+5];
priority_queue<ll, vector<ll>, greater<ll> > q1;
priority_queue<ll> q2;
void solve() {
n = rd();
FOR(i,1,n) r[i].a = rd(), r[i].b = rd();
ROF(i,n,1) rmax[i] = max(rmax[i+1], r[i].b);
sort(r+1, r+1+n, cmp);
ll ans = INF;
for(int i=1;i<=n;++i) {
while( !q1.empty() && q1.top() < r[i].a ) {
q2.push(q1.top());
q1.pop();
}
ll cons = rmax[i+1];
if( cons >= r[i].a ) ans = min(ans, cons - r[i].a);
else {
ans = min(ans, r[i].a - cons);
if( !q2.empty() ) ans = min(ans, r[i].a - q2.top());
if( !q1.empty() ) ans = min(ans, q1.top() - r[i].a);
}
if( r[i].b >= r[i].a ) q1.push(r[i].b);
else q2.push(r[i].b);
}
printf("%lld\n", ans);
while( !q1.empty() ) q1.pop();
while( !q2.empty() ) q2.pop();
for(int i = 1; i <= n; ++i) rmax[i] = 0;
ans = INF;
}
int main() {
int T = rd(); while( T-- ) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 177ms
memory: 7580kb
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 0 0 0 5 0 10 5 10 3 0 10 5 0 5 0 10 5 10 3 0 10 5 0 227224431 751178206 817134268 621036115 552575846 480187961 20455370 407439590 370094097 138022625 584548454 112341371 299136072 133505742 7829291 162619378 525194765 331371108 69508481 245389496 176221477 550674167 111344808 9...
result:
wrong answer 6th lines differ - expected: '1000000000', found: '0'