QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#836570 | #9730. Elevator II | yylx | WA | 0ms | 3604kb | C++14 | 1.2kb | 2024-12-29 00:47:43 | 2024-12-29 00:47:44 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Person {
int id;
int l;
int r;
};
bool comparePeople(const Person& a, const Person& b) {
if (a.l != b.l) {
return a.l < b.l;
}
return a.r < b.r;
}
int main() {
int T;
cin >> T;
while (T--) {
int n, f;
cin >> n >> f;
vector<Person> people(n);
for (int i = 0; i < n; ++i) {
people[i].id = i + 1;
cin >> people[i].l >> people[i].r;
}
sort(people.begin(), people.end(), comparePeople);
long long current_cost = 0;
int current_floor = f;
vector<int> current_permutation;
for (int i = 0; i < n; ++i) {
current_cost += max(0, people[i].l - current_floor);
current_floor = people[i].l;
current_cost += people[i].r - people[i].l;
current_floor = people[i].r;
current_permutation.push_back(people[i].id);
}
cout << current_cost << endl;
for (int i = 0; i < n; ++i) {
cout << current_permutation[i] << (i == n - 1 ? "" : " ");
}
cout << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 2 3 1 4 6 1 2
result:
wrong answer Participant's cost is 6, which is worse than jury's cost 5 (test case 2)