QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874068#9730. Elevator IIyylxWA 0ms3584kbC++141.1kb2025-01-27 13:34:392025-01-27 13:34:41

Judging History

你现在查看的是最新测评结果

  • [2025-01-27 13:34:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3584kb
  • [2025-01-27 13:34:39]
  • 提交

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)