| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1363319 | AMnu | Safety (NOI18_safety) | C++20 | 56 ms | 3648 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, H, A;
ll ans, sh;
priority_queue <ll> lef;
priority_queue <ll,vector<ll>,greater<ll> > rig;
int main () {
cin >> N >> H >> A;
lef.push(A);
rig.push(A);
for (int i=1;i<N;i++) {
cin >> A;
sh += H;
if (A < lef.top()-sh) {
ans += (lef.top()-sh) - A;
rig.push(lef.top()-sh-sh);
lef.pop();
lef.push(A+sh);
lef.push(A+sh);
}
else if (A > rig.top()+sh) {
ans += A - (rig.top()+sh);
lef.push(rig.top()+sh+sh);
rig.pop();
rig.push(A-sh);
rig.push(A-sh);
}
else {
lef.push(A+sh);
rig.push(A-sh);
}
}
cout << ans << "\n";
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
