QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859857#9730. Elevator IIMVP_HarryWA 0ms3712kbC++201.1kb2025-01-18 03:47:532025-01-18 03:47:55

Judging History

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

  • [2025-01-18 03:47:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3712kb
  • [2025-01-18 03:47:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#ifdef LOCAL
    #include <bits/debug.h>
#else
    #define dbg(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int T;
    cin >> T;

    while (T--) {
        int n, f;
        cin >> n >> f;

        ll ans = 0;
        int max_r = 0;
        vector<tuple<int, int, int>> up, down;
        for (int i = 0; i < n; i++) {
            int l, r;
            cin >> l >> r;
            if (l >= f) {
                up.emplace_back(l, r, i);
                max_r = max(max_r, r);
            }
            else {
                ans += r - l;
                down.emplace_back(l, r, i);
            }
        }

        sort(up.begin(), up.end());
        sort(down.begin(), down.end());

        if (!up.empty()) {
            ans += max_r - f;
        }

        cout << ans << endl;
        for (auto [_, __, x] : up) {
            cout << x + 1 << " ";
        }
        for (auto [_, __, x] : down) {
            cout << x + 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: 3712kb

input:

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

output:

7
3 1 4 2 
5
2 1 

result:

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