QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#852730 | #9730. Elevator II | ucup-team987# | WA | 55ms | 3620kb | C++23 | 2.4kb | 2025-01-11 13:43:15 | 2025-01-11 13:43:15 |
Judging History
answer
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
void Solve() {
int n, f;
IN(n, f);
vector<int> L(n), R(n);
for (int i : Rep(0, n)) {
IN(L[i], R[i]);
}
vector<int> order(ALL(Rep(0, n)));
ranges::stable_sort(order, {}, LAMBDA(i, pair(R[i], -L[i])));
basic_string<int> s;
for (int i : order) {
while (Sz(s) && L[s.back()] >= L[i]) {
s.pop_back();
}
s += i;
}
vector<int> ans;
ans.reserve(n);
vector<bool> done(n);
for (int i : s) {
if (L[i] >= f) {
ans.push_back(i);
done[i] = true;
}
}
order.clear();
for (int i : Rep(0, n)) {
if (done[i]) {
continue;
}
order.push_back(i);
}
ranges::sort(order, {}, LAMBDA(i, L[i]));
while (Sz(order)) {
ans.push_back(order.back());
order.pop_back();
}
int64_t mn = 0;
int cur = f;
for (int i : ans) {
mn += max(L[i] - cur, 0);
mn += R[i] - L[i];
cur = R[i];
}
OUT(mn);
OUT(ans | MAP(i, i + 1));
}
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 ALL(r) begin(r), end(r)
#define MAP(...) views::transform(LAMBDA(__VA_ARGS__))
#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)
#define Sz(r) int(size(r))
#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))
#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')
#endif // __INCLUDE_LEVEL__ == 1
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 3 4 1 2 5 2 1
result:
ok ok 2 cases (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 55ms
memory: 3620kb
input:
6100 19 52 51 98 2 83 40 58 96 99 39 55 72 94 15 17 4 15 48 99 2 99 77 78 35 77 44 62 79 81 30 31 1 48 48 76 68 99 60 66 6 19 44 53 64 92 17 28 67 98 9 99 40 65 16 27 99 100 15 56 4 6 24 97 84 96 47 49 37 38 77 79 13 40 13 92 71 100 47 93 90 91 72 81 15 48 32 71 19 17 95 99 10 23 18 100 90 93 52 92 ...
output:
568 4 14 11 6 18 19 1 17 9 13 3 5 12 15 7 8 10 2 16 242 4 2 1 6 3 5 441 11 1 13 5 8 14 12 6 7 16 4 15 2 10 9 3 733 7 3 1 4 17 8 16 5 12 10 19 13 14 6 11 18 9 15 2 251 10 5 6 2 8 12 4 14 11 1 15 3 9 13 7 495 11 10 6 7 2 13 20 4 8 5 15 9 16 14 1 19 3 12 18 17 104 1 4 3 2 197 3 8 2 1 5 6 4 9 10 7 146 4...
result:
wrong answer Participant's cost is 568, which is worse than jury's cost 524 (test case 1)