QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#320917#5441. Quartz CollectionduckindogWA 1ms6340kbC++141.4kb2024-02-03 23:46:002024-02-03 23:46:02

Judging History

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

  • [2024-02-03 23:46:02]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6340kb
  • [2024-02-03 23:46:00]
  • 提交

answer

//from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e5 + 10;

int n, m;
struct quartz {
  int a, b, t;
  quartz() : a(0), b(0), t(0) {}
  quartz(int a, int b, int t) : a(a), b(b), t(t) {}
} x[N];

int d[N];
int cal() {
  sort(x + 1, x + n + 1, [&](const auto&x, const auto& y) {
    return make_pair(x.a - x.b, x.a) < make_pair(y.a - y.b, y.a);
  });
  for (int i = 1; i <= n; ++i) d[i] = x[i].a - x[i].b;
  int answer = d[1];
  bool player = 0;
  int it = 2;
  while (it <= n) {
    if (it < n) {
      if (d[it] + d[it + 1] <= d[it]) {
        if (player) answer += d[it] + d[it + 1];
        it += 2;
        player = 1 - player;
        continue;
      }
    }
    if (player) answer += d[it];
    it += 1;
    player = 1 - player;
  }

  for (int i = 1; i <= n; ++i) answer += x[i].b;
  return answer;
}

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }

  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    int a, b; cin >> a >> b;
    x[i] = {a, b, i};
  }
  cout << cal() << "\n";
  for (int i = 1; i <= m; ++i) {
    int t, a, b; cin >> t >> a >> b;
    for (int j = 1; j <= n; ++j) if (x[j].t == t) x[j] = {a, b, t};
    cout << cal() << "\n";
  }
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6340kb

input:

4 5
2 4
5 7
1 7
2 1
4 5 2
1 6 2
4 4 3
2 1 3
3 6 6

output:

14
17
15
14
10
13

result:

wrong answer 1st numbers differ - expected: '13', found: '14'