QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619050#2442. Welcome PartyPlentyOfPenalty#WA 446ms9920kbC++201.0kb2024-10-07 12:44:072024-10-07 12:44:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-07 12:44:08]
  • 评测
  • 测评结果:WA
  • 用时:446ms
  • 内存:9920kb
  • [2024-10-07 12:44:07]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define endl '\n'
#define log(...) (void(0))
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;

const int N = 200011, INF = 5e18;
pll a[N];
multiset<ll> S;
int main() {
#ifdef memset0
  freopen("E.in", "r", stdin);
#endif
  cin.tie(0)->sync_with_stdio(0);
  int task;
  cin >> task;
  while (task--) {
    S.clear();
    S.insert(-INF), S.insert(INF);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second, S.insert(a[i].second);
    sort(a + 1, a + n + 1);
    ll ans = 5e18;
    for (int i = n; i; --i) {
      S.erase(S.find(a[i].second));
      auto it = S.lower_bound(a[i].first);
      ll nxt = *it;
      ll pre = *--it;
      ans = min(ans, min(nxt - a[i].first, a[i].first - pre));
    }
    cout << ans << '\n';
  }
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 446ms
memory: 9920kb

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
40
0
10
5
10
3
0
10
30
35
5
2
30
10
10
3
0
10
5
0
-905678998765289737
-444708913638021301
-58720078032695089
-338841380939916770
-699945920641875061
-836907779174341255
-874270770036385886
-360096155277228885
-864345912855934430
-903502723224110258
-46030...

result:

wrong answer 10th lines differ - expected: '5', found: '40'