QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#635336 | #9450. Balloon Robot | ucup-team1264# | AC ✓ | 144ms | 9356kb | C++20 | 1.7kb | 2024-10-12 19:32:06 | 2024-10-14 16:43:29 |
Judging History
answer
// https://www.youtube.com/watch?v=CrymicX875M
// Angel of mercy
// How did you move me
// Why am I on my feet again
#ifndef ONLINE_JUDGE
#include "templates/debug.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
void solve() {
int n, m, p; cin >> n >> m >> p;
// p linear functions
vector<int> s(n);
for (int i = 0; i < n; i++) cin >> s[i], s[i]--;
// time, k, b
vector<array<int, 3>> events;
for (int i = 0; i < p; i++) {
int a, t; cin >> a >> t;
t %= m;
int x = s[--a];
if (t <= x) {
// (x - t) - k
events.push_back({0, -1, x - t});
events.push_back({(x - t) + 1, 0, m});
} else {
// also (x - t) - k
// but x - t < 0
events.push_back({0, -1, x - t + m});
if (x - t != -1) events.push_back({(x - t + m) + 1, 0, m});
}
}
sort(events.begin(), events.end());
i64 ans = 1e18, ksum = 0, bsum = 0;
int ev = events.size();
for (int i = 0, j = 0; i < ev; i = j) {
for (j = i; j < ev && events[j][0] == events[i][0]; j++);
int t = events[i][0], tr = j == ev ? m : events[j][0];
for (int l = i; l < j; l++) {
int k = events[l][1], b = events[l][2];
ksum += k; bsum += b;
}
ans = min(ans, ksum * (tr - 1) + bsum);
}
cout << ans << "\n";
}
#undef int
// Make bold hypotheses and verify carefully
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t = 1;
cin >> t;
while (t--) {
solve();
};
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
4 2 3 3 1 2 1 1 2 1 1 4 2 3 5 1 2 1 1 2 1 1 2 1 3 1 4 3 7 5 3 5 7 1 5 2 1 3 3 1 5 2 5 2 100 2 1 51 1 500 2 1000
output:
1 4 5 50
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 144ms
memory: 9356kb
input:
1004 22 9426 26 1165 5248 8331 9055 1161 7381 2188 7489 5131 8434 2166 3981 6302 7188 4858 856 7797 9129 7839 1676 25 9053 20 6 22 68 12 16 11 63 17 49 5 10 21 68 17 80 18 18 10 28 15 55 14 80 1 45 21 67 5 74 13 4 3 34 7 80 9 95 5 52 8 31 2 53 7 22 5 99 20 66 12 2 33 9526 92 558 7460 280 7952 5186 9...
output:
94067 360219 223074 30971 171844 312753 0 158169 294738 291604 115632 59327 221328 287851 30518 337118 181724 249419 66367 10347 208411 180496 287130 40736 264604 278208 33792 191523 111583 31867 21143 232153 149868 191831 238832 63626 258936 133059 105618 237774 53942 342921 275883 110295 149350 20...
result:
ok 1004 lines
Extra Test:
score: 0
Extra Test Passed