QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#742726 | #9730. Elevator II | shenchuan_fan | WA | 85ms | 3684kb | C++20 | 1.1kb | 2024-11-13 17:10:50 | 2024-11-13 17:10:52 |
Judging History
answer
/*
24 HZ E
*/
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
using LL = long long;
typedef pair<int, int> PII;
const int N = 1e7 + 10, M = 5010, mod = 998244353;
const int inf = 1e9;
void solve() {
int n, f;
cin >> n >> f;
multiset <PII> L;
multiset <int> R;
vector <PII> a(n + 1);
for(int i = 1; i <= n; i++){
cin >> a[i].x >> a[i].y;
L.insert({a[i].x, i});
}
int ans = 0;
R.insert(f);
vector <int> perm;
while(R.size() && L.size()){
PII t = {*R.rbegin(), 0};
auto it = L.lower_bound(t);
if(it == L.end()){
R.erase(R.find(t.x));
PII bg = *L.begin();
R.insert(a[bg.y].y);
ans += a[bg.y].y - bg.x;
L.erase(L.find(bg));
perm.push_back(bg.y);
continue;
}else{
PII to = *it;
ans += to.x - t.x;
ans += a[to.y].y - to.x;
perm.push_back(to.y);
R.insert(a[to.y].y);
L.erase(L.find(to));
}
}
cout << ans << "\n";
for(auto p: perm) cout << p << " ";
cout << "\n";
}
signed main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 4 2 3 6 1 3 2 7 5 6 2 5 2 4 6 8
output:
11 3 2 1 4 5 2 1
result:
ok ok 2 cases (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 85ms
memory: 3684kb
input:
6100 19 52 51 98 2 83 40 58 96 99 39 55 72 94 15 17 4 15 48 99 2 99 77 78 35 77 44 62 79 81 30 31 1 48 48 76 68 99 60 66 6 19 44 53 64 92 17 28 67 98 9 99 40 65 16 27 99 100 15 56 4 6 24 97 84 96 47 49 37 38 77 79 13 40 13 92 71 100 47 93 90 91 72 81 15 48 32 71 19 17 95 99 10 23 18 100 90 93 52 92 ...
output:
554 19 18 16 6 4 2 10 8 7 11 14 15 12 5 3 13 9 17 1 228 6 4 5 3 1 2 424 16 11 3 14 5 1 9 10 2 13 15 4 7 8 6 12 753 7 17 1 2 9 4 15 18 8 3 11 6 14 13 19 10 12 5 16 269 11 2 7 12 8 13 9 3 15 10 1 5 14 6 4 457 12 11 17 18 3 16 4 19 20 1 14 10 9 15 5 7 8 6 13 2 123 2 3 4 1 216 1 7 3 10 2 8 9 4 6 ...
result:
wrong answer Participant declares the cost to be 554, but the plan actually costs 625 (test case 1)