QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#632614 | #9450. Balloon Robot | ucup-team987# | AC ✓ | 132ms | 5352kb | C++23 | 2.7kb | 2024-10-12 13:39:53 | 2024-10-14 16:41:32 |
Judging History
answer
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
void Solve() {
int n, m, p;
IN(n, m, p);
vector<int> s(n);
IN(s);
ranges::for_each(s, LAMBDA(x, --x));
vector<int> v;
while (p--) {
int a, b;
IN(a, b);
--a, --b;
v.push_back(Mod(b - s[a], m));
}
auto U = v;
ranges::sort(U);
APPLY(U.erase, ranges::unique(U));
vector<int64_t> f(Sz(U) + 1);
for (int r : v) {
int ri = int(ranges::lower_bound(U, r) - U.begin());
f[ri] -= r;
if (r > 0) {
f[0] += m - r;
f[ri] -= m - r;
}
}
for (int i : Rep(1, Sz(f))) {
f[i] += f[i - 1];
}
int64_t ans = INF64;
for (int i : Rep(0, Sz(U))) {
int64_t cur = f[i] + int64_t(Sz(v)) * U[i];
SetMin(ans, cur);
}
OUT(ans);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
IN(t);
while (t--) {
Solve();
}
}
#elif __INCLUDE_LEVEL__ == 1
#include <bits/stdc++.h>
template <class T> concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;
template <class T> concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;
namespace std {
istream& operator>>(istream& is, Range auto&& r) {
for (auto&& e : r) is >> e;
return is;
}
istream& operator>>(istream& is, Tuple auto&& t) {
apply([&](auto&... xs) { (is >> ... >> xs); }, t);
return is;
}
ostream& operator<<(ostream& os, Range auto&& r) {
auto sep = "";
for (auto&& e : r) os << exchange(sep, " ") << e;
return os;
}
ostream& operator<<(ostream& os, Tuple auto&& t) {
auto sep = "";
apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);
return os;
}
} // namespace std
using namespace std;
#define LAMBDA(x, ...) ([&](auto&& x) -> decltype(auto) { return __VA_ARGS__; })
#define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; })
#define LAMBDA3(x, y, z, ...) ([&](auto&& x, auto&& y, auto&& z) -> decltype(auto) { return __VA_ARGS__; })
#define ALL(r) begin(r), end(r)
#define APPLY(f, r, ...) LAMBDA(_r, f(ALL(_r), ##__VA_ARGS__))(r)
#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)
#define Sz(r) int(size(r))
#define SetMin(...) LAMBDA2(x, y, y < x && (x = y, 1))(__VA_ARGS__)
#define INF64 (INT64_MAX / 2)
#define DivFloor(...) LAMBDA2(x, y, x / y - ((x ^ y) < 0 && x % y != 0))(__VA_ARGS__)
#define Floor(...) LAMBDA3(x, m, r, DivFloor(x - r, m) * m + r)(__VA_ARGS__)
#define Mod(...) LAMBDA2(x, m, x - Floor(x, m, 0))(__VA_ARGS__)
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')
#endif // __INCLUDE_LEVEL__ == 1
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
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: 132ms
memory: 5352kb
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