QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864337 | #9730. Elevator II | Nelofus | WA | 0ms | 3712kb | C++20 | 1.4kb | 2025-01-20 14:58:05 | 2025-01-20 14:58:11 |
Judging History
answer
// Code by Heratino & Nelofus
// 星屑落ちて 華は散っても
// キラめく舞台に 生まれて変わる
// 新たな私は 未知なる運命
// 新たな私は まだ見ぬ戯曲
// 愛城華恋は 舞台に一人
// 愛城華恋は 次の舞台へ
#include <bits/stdc++.h>
using i64 = long long;
//{{{
template<typename T>
inline void chkmin(T &a, const T &b) {if (a > b) a = b;}
template<typename T>
inline void chkmax(T &a, const T &b) {if (a < b) a = b;}
//}}}
inline void solve() {
int n, f;
std::cin >> n >> f;
std::vector<int> per(n);
std::vector<std::pair<int, int>> seq(n);
for (int i = 0; i < n; i++)
per[i] = i;
for (auto &[l, r] : seq)
std::cin >> l >> r;
std::sort(per.begin(), per.end(), [&](const int &x, const int &y) {
return seq[x].first < seq[y].first;
});
i64 ans = 0;
std::vector<int> a, b;
for (const int &i : per) {
auto &[l, r] = seq[i];
ans += r - l;
if (r > f) {
ans += std::max(0, l - f);
f = r;
b.push_back(i);
} else {
a.push_back(i);
}
}
std::reverse(b.begin(), b.end());
std::cout << ans << '\n';
for (const int &x : a)
std::cout << x + 1 << ' ';
for (const int &x : b)
std::cout << x + 1 << ' ';
std::cout << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T;
std::cin >> T;
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3712kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 1 4 3 2 5 1 2
result:
wrong answer Participant declares the cost to be 11, but the plan actually costs 12 (test case 1)