QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#856417#9730. Elevator IIshi2ukuWA 1ms3712kbC++141.3kb2025-01-13 23:26:252025-01-13 23:26:26

Judging History

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

  • [2025-01-13 23:26:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3712kb
  • [2025-01-13 23:26:25]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void solve() {
    int n, f;
    cin >> n >> f;
    vector<pii> a(n);
    // vector<int> b(n), c(n), vis(n);
    ll ans = 0;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second, mp[a[i].first] = a[i].second, ans += a[i].second - a[i].first;
    sort(a.begin(), a.end());
    vector<int> order;
    vector<int> vis(n);
    int cur = f;
    for (int i = 0; i < n; ++i) {
        if (a[i].first > cur) {
            order.push_back(i);

            ans += a[i].first - cur;
            cur = a[i].second;
            vis[i] = 1;
        } else {
            if (a[i].second > cur) {
                order.push_back(i);
                cur = a[i].second;
                vis[i] = 1;
            }
        }
    }
    cout << ans << '\n';
    for (int i = n - 1; i >= 0; --i)
        if (!vis[i]) order.push_back(i);
    for (const auto u : order) cout << u + 1 << " ";
    cout << '\n';
}
int main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) solve();
}
/*
2
4 2
3 6
1 3
2 7
5 6
2 5
2 4
6 8
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3712kb

input:

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

output:

11
1 2 4 3 
5
2 1 

result:

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