QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#80199#2616. Attack Orderwoxiangbaile#WA 2ms3456kbC++141.1kb2023-02-23 08:26:452023-02-23 08:26:48

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:26:48]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3456kb
  • [2023-02-23 08:26:45]
  • 提交

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) {
    rep(j, 1, n) if (j != i) r[i] += b[j];
  }
  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: 0
Wrong Answer
time: 2ms
memory: 3456kb

input:

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

output:

No
Yes
No

result:

wrong answer expected YES, found NO [1st token]