| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 969910 | VMaksimoski008 | Safety (NOI18_safety) | C++17 | 82 ms | 5476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int32_t main() {
ll n, h, ans = 0;
cin >> n >> h;
priority_queue<ll> L;
priority_queue<ll, vector<ll>, greater<ll> > R;
for(int i=0; i<n; i++) {
ll x;
cin >> x;
if(!i) {
L.push(x);
R.push(x);
continue;
}
ll range = i * h;
if(x + range < L.top()) {
L.push(x + range);
ans += L.top() - (x + range);
L.push(x + range);
R.push(L.top() - 2 * range);
L.pop();
} else if(x - range > R.top()) {
R.push(x - range);
ans += (x - range) - R.top();
R.push(x - range);
L.push(R.top() + 2 * range);
R.pop();
} else {
L.push(x + range);
R.push(x - range);
}
}
cout << ans << '\n';
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
