QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#763441 | #9730. Elevator II | Konggee | WA | 0ms | 3524kb | C++20 | 1.8kb | 2024-11-19 20:17:21 | 2024-11-19 20:17:22 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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)