QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#763441#9730. Elevator IIKonggeeWA 0ms3524kbC++201.8kb2024-11-19 20:17:212024-11-19 20:17:22

Judging History

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

  • [2024-11-19 20:17:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3524kb
  • [2024-11-19 20:17:21]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <array>
#include <tuple>
#include <cassert>
#include <random>
#include <chrono>
#define int long long
#define endl "\n"
using namespace std;
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = std::pair<int, int>;

//std::mt19937_64 rng {std::chrono::steady_clock::now().time_since_epoch().count()};
constexpr int N = 2e5 + 10;
struct ac {
    int l, r;
    int i;
};

bool cmp (ac x, ac y) {
    return x.l < y.l;
}
bool com (ac x, ac y) {
    return x.r > y.r;
}
void solve() {
    int n, m;
    cin >> n >> m;
    struct ac a[n + 1];
    for (int i = 1; i <= n; i ++) {
        cin >> a[i].l >> a[i].r;
        a[i].i = i;
    }
    sort(a + 1, a + n + 1, cmp);
    int mx = m;
    int ans = 0;
    int res = 0;
    int cnt = 1;
    map<int, int> mp;
    vector<int> vr;
    for (int i = 1; i <= n; i ++) {
        if (a[i].l > mx) {
            if(res == 0) continue;
            vr.push_back(res);
            mp[res] = 1;
            cnt = i;
            ans += a[i].l - mx;
        }
        if(mx < a[i].r) {
            mx = a[i].r;
            res = a[i].i;
        }
        ans += a[i].r - a[i].l;
    }
    sort(a + 1, a + n + 1, com);
            //cout << i << endl;
    for (int j = 1; j <= n; j ++) {
        if(mp[a[j].i]) continue;
        vr.push_back(a[j].i);
    }
    cout << ans << endl;
    for (auto t : vr) {
        cout << t << " ";
    }
    cout << endl;
    return;
}
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int T = 1;
    std::cin >> T;
    while (T --) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

11
3 1 4 2 
2
2 1 

result:

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