# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
158510 |
2019-10-17T13:24:01 Z |
gs18103 |
Safety (NOI18_safety) |
C++14 |
|
44 ms |
4676 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[202020];
priority_queue <ll> L;
priority_queue <ll, vector <ll>, greater <ll> > R;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int n; ll h;
cin >> n >> h;
for(int i = 1; i <= n; i++) {
cin >> s[i];
}
ll l = s[1], r = s[1], ans = 0;
L.push(s[1]), R.push(s[1]);
for(int i = 2; i <= n; i++) {
l -= h, r += h;
if(s[i] < l) {
ans += l - s[i];
L.push(s[i] + h * (i - 1));
L.push(s[i] + h * (i - 1));
R.push(l - 2 * h * (i - 1));
L.pop();
}
else if(s[i] > r) {
ans += s[i] - r;
R.push(s[i] - h * (i - 1));
R.push(s[i] - h * (i - 1));
L.push(r + 2 * h * (i - 1));
R.pop();
}
else {
l = r = s[i];
L.push(s[i] + h * (i - 1));
R.push(s[i] - h * (i - 1));
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
4676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |