QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#836570#9730. Elevator IIyylxWA 0ms3604kbC++141.2kb2024-12-29 00:47:432024-12-29 00:47:44

Judging History

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

  • [2024-12-29 00:47:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-12-29 00:47:43]
  • 提交

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;
}

詳細信息

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)