QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#874068 | #9730. Elevator II | yylx | WA | 0ms | 3584kb | C++14 | 1.1kb | 2025-01-27 13:34:39 | 2025-01-27 13:34:41 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Person {
int id;
int l, 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(), [](const Person& a, const Person& b) {
return a.r < b.r;
});
long long total_cost = 0;
int current_floor = f;
vector<int> order;
for (int i = 0; i < n; ++i) {
total_cost += max(0, people[i].l - current_floor);
total_cost += people[i].r - people[i].l;
current_floor = people[i].r;
order.push_back(people[i].id);
}
cout << total_cost << endl;
for (int i = 0; i < n; ++i) {
cout << order[i] << (i == n - 1 ? "" : " ");
}
cout << endl;
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3584kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 2 1 4 3 6 1 2
result:
wrong answer Participant's cost is 6, which is worse than jury's cost 5 (test case 2)