QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619188 | #2442. Welcome Party | untitledtwo# | WA | 281ms | 11736kb | C++17 | 1.1kb | 2024-10-07 13:27:31 | 2024-10-07 13:27:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
typedef long long ll;
#define fi first
#define se second
#define PB push_back
#define MP make_pair
pair<ll, ll> a[MAXN];
set<ll> Set;
ll mx[MAXN];
signed main() {
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
#endif
int Case;
scanf("%d", &Case);
while (Case --) {
Set.clear();
int n;
scanf("%d", &n);
for (int i = 1; i <= n ; ++ i) scanf("%lld%lld", &a[i].fi, &a[i].se);
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
ll ans = (ll)1e19;
for (int i = 1; i <= n ; ++ i) mx[i] = max(mx[i - 1], a[i].se);
for (int i = n; i >= 1 ; -- i) {
ll t = -(ll)1e19;
auto nxt = Set.lower_bound(a[i].fi), pre = nxt;
if (pre != Set.begin()) {
-- pre;
if (abs(t - a[i].fi) > abs(*pre - a[i].fi)) t = *pre;
}
if (nxt != Set.end()) {
if (abs(t - a[i].fi) > abs(*nxt - a[i].fi)) t = *nxt;
}
ans = min(ans, abs(max(mx[i - 1], t) - a[i].fi));
Set.insert(a[i].se);
// cout << a[i].fi << " " << mx[i - 1] << " " << t << endl;
}
printf("%lld\n", ans);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 281ms
memory: 11736kb
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 5 10 3 0 10 5 0 5 0 10 5 10 3 0 10 5 0 146595730144168239 13421384895232913 21076180420813408 183538167814754058 46751451188711820 365292306661444331 23639646046527434 40476687889457528 270663364266559542 139940820548070767 48500389324554138 100200...
result:
wrong answer 31st lines differ - expected: '10974087366700578', found: '13421384895232913'