QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#852799 | #9730. Elevator II | ucup-team045# | WA | 0ms | 3424kb | C++20 | 1.3kb | 2025-01-11 14:05:41 | 2025-01-11 14:05:41 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, f;
cin >> n >> f;
vector<pair<int, int> > p(n);
LL sum = 0;
for(int i = 0; i < n; i++){
int l, r;
cin >> l >> r;
sum += r - l;
p[i] = {l, r};
}
vector<int> id(n);
iota(id.begin(), id.end(), 0);
sort(id.begin(), id.end(), [&](int a, int b){
return p[a] < p[b];
});
vector<int> q, ans;
int R = f;
for(auto x : id){
auto [l, r] = p[x];
if (r <= R){
q.push_back(x);
continue;
}
ans.push_back(x);
R = r;
sum += max(0, l - R);
}
cout << sum << '\n';
sort(q.begin(), q.end(), [&](int a, int b){
return p[a].second > p[b].second;
});
for(auto x : q) ans.push_back(x);
for(auto x : ans) cout << x + 1 << ' ';
cout << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3424kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 2 3 1 4 4 2 1
result:
wrong answer Participant declares the cost to be 4, but the plan actually costs 5 (test case 2)