QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#852799#9730. Elevator IIucup-team045#WA 0ms3424kbC++201.3kb2025-01-11 14:05:412025-01-11 14:05:41

Judging History

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

  • [2025-01-11 14:05:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3424kb
  • [2025-01-11 14:05:41]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
using LL = long long;

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--){
        int n, f;
        cin >> n >> f;
        vector<pair<int, int> > p(n);
        LL sum = 0;
        for(int i = 0; i < n; i++){
            int l, r;
            cin >> l >> r;
            sum += r - l;
            p[i] = {l, r};
        }
        vector<int> id(n);
        iota(id.begin(), id.end(), 0);
        sort(id.begin(), id.end(), [&](int a, int b){
            return p[a] < p[b];
        });
        vector<int> q, ans;
        int R = f;
        for(auto x : id){
            auto [l, r] = p[x];
            if (r <= R){
                q.push_back(x);
                continue;
            }
            ans.push_back(x);
            R = r;
            sum += max(0, l - R);
        }
        cout << sum << '\n';
        sort(q.begin(), q.end(), [&](int a, int b){
            return p[a].second > p[b].second;
        });
        for(auto x : q) ans.push_back(x);
        for(auto x : ans) cout << x + 1 << ' ';
        cout << '\n';
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3424kb

input:

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

output:

11
2 3 1 4 
4
2 1 

result:

wrong answer Participant declares the cost to be 4, but the plan actually costs 5 (test case 2)