QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#80198#2616. Attack Orderwoxiangbaile#WA 2ms3440kbC++141.2kb2023-02-23 08:22:272023-02-23 08:22:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-23 08:22:31]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3440kb
  • [2023-02-23 08:22:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define drep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << ' '; cout << endl

const int INF = 0x3f3f3f3f;

const int N = 1e6 + 10;

int read() {
  int x = 0, f = 1; char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  return x * f;
}

int n, a[N], b[N], l[N], r[N], o[N];

void solve() {
  n = read();
  rep(i, 1, n) {
    a[i] = read(), b[i] = read();
    l[i] = r[i] = a[i], o[i] = i;
  }
  rep(i, 1, n) {
    int mx = -INF, mn = INF;
    rep(j, 1, n) if (j != i) {
      mx = max(mx, b[j]);
      mn = min(mn, b[j]);
    }
    l[i] += mn, r[i] += mx;
  }
  sort(o + 1, o + n + 1, [](int i, int j) {
    return l[i] == l[j] ? r[i] < r[j] : l[i] < l[j];
  });
  rep(i, 1, n - 1) if (r[o[i]] > l[o[i + 1]]) {
    printf("No\n");
    return;
  }
  printf("Yes\n");
}

int main() {
  for (int tc = read(); tc; -- tc) solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3364kb

input:

3
2
15 25
10 5
3
7 0
7 3
10 0
3
10 10
20 20
30 30

output:

Yes
Yes
No

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3440kb

input:

1000
4
0 1
0 2
2 2
0 0
4
2 2
1 1
1 1
0 0
4
2 1
1 2
1 0
2 1
3
2 1
1 0
1 1
4
2 0
2 2
1 2
1 2
3
1 0
3 0
0 3
4
1 1
1 0
1 2
1 2
2
1 2
3 1
4
1 2
1 0
2 0
0 2
2
3 3
0 2
4
2 0
1 0
2 1
0 1
3
1 1
1 0
0 3
4
1 1
2 1
0 2
1 1
4
1 2
2 2
1 0
2 1
4
0 0
1 0
0 1
0 1
3
0 1
2 3
0 0
3
3 1
3 2
1 1
4
1 0
0 0
1 1
2 1
4
2 1
1...

output:

No
No
No
Yes
No
No
No
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Ye...

result:

wrong answer expected NO, found YES [4th token]