QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#856417 | #9730. Elevator II | shi2uku | WA | 1ms | 3712kb | C++14 | 1.3kb | 2025-01-13 23:26:25 | 2025-01-13 23:26:26 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void solve() {
int n, f;
cin >> n >> f;
vector<pii> a(n);
// vector<int> b(n), c(n), vis(n);
ll ans = 0;
map<int, int> mp;
for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second, mp[a[i].first] = a[i].second, ans += a[i].second - a[i].first;
sort(a.begin(), a.end());
vector<int> order;
vector<int> vis(n);
int cur = f;
for (int i = 0; i < n; ++i) {
if (a[i].first > cur) {
order.push_back(i);
ans += a[i].first - cur;
cur = a[i].second;
vis[i] = 1;
} else {
if (a[i].second > cur) {
order.push_back(i);
cur = a[i].second;
vis[i] = 1;
}
}
}
cout << ans << '\n';
for (int i = n - 1; i >= 0; --i)
if (!vis[i]) order.push_back(i);
for (const auto u : order) cout << u + 1 << " ";
cout << '\n';
}
int main() {
cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--) solve();
}
/*
2
4 2
3 6
1 3
2 7
5 6
2 5
2 4
6 8
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 1 2 4 3 5 2 1
result:
wrong answer Participant declares the cost to be 11, but the plan actually costs 14 (test case 1)