QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740616 | #9730. Elevator II | liulinghongxiu | WA | 0ms | 3620kb | C++14 | 1.3kb | 2024-11-13 10:45:01 | 2024-11-13 10:45:02 |
Judging History
answer
#include <bits/stdc++.h>
#define endl "\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
const int mod = 998244353;
const int inf = 1e16 + 10;
const int N = 1e6 + 10;
int n, now;
void solve()
{
cin >> n >> now;
vector<int> vis(n + 1);
vector<pii> s(n + 1);
for (int i = 1; i <= n; i++)
{
auto &[x, y] = s[i];
cin >> x >> y;
}
sort(s.begin() + 1, s.end());
vector<int> op;
int res = 0;
for (int i = 1; i <= n; i++)
{
auto &[x, y] = s[i];
if (y > now)
{
vis[i] = 1;
op.push_back(i);
res += max(x - now, 0LL);
res += max(y - x, 0LL);
now = y;
}
}
for (int i = n; i >= 1; i--)
{
auto &[x, y] = s[i];
if (vis[i] == 0)
{
op.push_back(i);
res += max(x - now, 0LL);
res += max(y - x, 0LL);
now = y;
}
}
cout << res << endl;
for (auto i : op)
cout << i << ' ';
cout << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T = 1;
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: 3620kb
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)