QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#320917 | #5441. Quartz Collection | duckindog | WA | 1ms | 6340kb | C++14 | 1.4kb | 2024-02-03 23:46:00 | 2024-02-03 23:46:02 |
Judging History
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";
}
}
Details
Tip: Click on the bar to expand more detailed information
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'