QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#790827#9730. Elevator IIEqvpkbzWA 47ms3620kbC++231.4kb2024-11-28 15:35:552024-11-28 15:35:55

Judging History

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

  • [2024-11-28 15:35:55]
  • 评测
  • 测评结果:WA
  • 用时:47ms
  • 内存:3620kb
  • [2024-11-28 15:35:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const ll N = 2e5 + 5;
const ll P = 998244353;
ll n, m, f;
struct node {
    int l, r;
    int id;
} st[N];
bool cmp(node a, node b) {
    if (a.l == b.l) {
        return a.r < b.r;
    }
    return a.l < b.l;
}
bool cmp1(node a, node b) {
    return a.r > b.r;
}
void solve() {
    cin >> n >> f;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> st[i].l >> st[i].r;
        ans += (st[i].r - st[i].l);
        st[i].id = i;
    }
    vector<int> v(n + 2), ve;

    sort(st + 1, st + 1 + n, cmp);
    int now = f, j = n + 1;
    for (int i = 1; i <= n; i++) {
        if (now < st[i].r) {
            if (now >= st[i].l) {
            } else {
                ans += st[i].l - now;
            }
            now = st[i].r;
            v[st[i].id] = 1;
            ve.push_back(st[i].id);
        }
    }
    sort(st + 1, st + n, cmp1);
    for (int i = 1; i <= n; i++) {
        if (!v[st[i].id]) {
            ve.push_back(st[i].id);
            st[i].id = 1;
        }
    }
    cout << ans << '\n';
    for (auto x : ve) {
        cout << x << ' ';
    }
    cout << '\n';
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

2
4 2
3 6
1 3
2 7
5 6
2 5
2 4
6 8

output:

11
2 3 1 4 
5
2 1 

result:

ok ok 2 cases (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 47ms
memory: 3600kb

input:

6100
19 52
51 98
2 83
40 58
96 99
39 55
72 94
15 17
4 15
48 99
2 99
77 78
35 77
44 62
79 81
30 31
1 48
48 76
68 99
60 66
6 19
44 53
64 92
17 28
67 98
9 99
40 65
16 27
99 100
15 56
4 6
24 97
84 96
47 49
37 38
77 79
13 40
13 92
71 100
47 93
90 91
72 81
15 48
32 71
19 17
95 99
10 23
18 100
90 93
52 92
...

output:

524
2 10 18 9 1 6 14 11 12 17 19 13 3 5 16 15 7 8 4 
194
5 2 6 1 3 4 
397
9 10 4 11 5 12 13 14 8 16 2 6 15 7 3 1 
733
2 9 15 7 11 3 10 8 6 4 17 5 16 13 12 18 14 19 1 
244
3 10 14 5 6 2 12 4 11 9 1 15 13 7 8 
422
17 18 1 6 10 2 7 13 9 4 12 20 14 5 15 19 8 16 3 11 
104
3 4 2 1 
187
4 3 8 1 2 6 7 5 9 1...

result:

wrong answer Participant declares the cost to be 524, but the plan actually costs 605 (test case 1)