# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
295574 | 2020-09-09T18:47:03 Z | RezwanArefin01 | Safety (NOI18_safety) | C++17 | 2000 ms | 1092 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; const int N = 2e5 + 5; int n, h, X; template<class T> void add(T &p, int x) { T q; while(!p.empty()) { q.push(p.top() + x); p.pop(); } p = q; } template<class T> void print(T p) { while(!p.empty()) { cout << p.top() << " "; p.pop(); } cout << endl; } int main() { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d", &n, &h); priority_queue<ll> L; priority_queue<ll, vector<ll>, greater<ll>> R; ll ans = 0 ; for(int i = 0; i < n; ++i) { scanf("%d", &X); add(L, -h); add(R, h); L.push(X); R.push(X); if(X < L.top()) { ans += L.top() - X; L.push(X); R.push(L.top()); R.pop(); L.pop(); } else if(X > R.top()) { ans += X - R.top(); R.push(X); L.push(R.top()); L.pop(); R.pop(); } } printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2073 ms | 1092 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 17 ms | 512 KB | Output is correct |
14 | Correct | 15 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 384 KB | Output is correct |
16 | Correct | 15 ms | 384 KB | Output is correct |
17 | Correct | 12 ms | 384 KB | Output is correct |
18 | Correct | 8 ms | 384 KB | Output is correct |
19 | Correct | 16 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 17 ms | 512 KB | Output is correct |
14 | Correct | 15 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 384 KB | Output is correct |
16 | Correct | 15 ms | 384 KB | Output is correct |
17 | Correct | 12 ms | 384 KB | Output is correct |
18 | Correct | 8 ms | 384 KB | Output is correct |
19 | Correct | 16 ms | 384 KB | Output is correct |
20 | Correct | 13 ms | 384 KB | Output is correct |
21 | Correct | 17 ms | 384 KB | Output is correct |
22 | Correct | 11 ms | 384 KB | Output is correct |
23 | Correct | 10 ms | 384 KB | Output is correct |
24 | Correct | 14 ms | 384 KB | Output is correct |
25 | Correct | 9 ms | 384 KB | Output is correct |
26 | Correct | 15 ms | 384 KB | Output is correct |
27 | Correct | 13 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 17 ms | 512 KB | Output is correct |
14 | Correct | 15 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 384 KB | Output is correct |
16 | Correct | 15 ms | 384 KB | Output is correct |
17 | Correct | 12 ms | 384 KB | Output is correct |
18 | Correct | 8 ms | 384 KB | Output is correct |
19 | Correct | 16 ms | 384 KB | Output is correct |
20 | Correct | 13 ms | 384 KB | Output is correct |
21 | Correct | 17 ms | 384 KB | Output is correct |
22 | Correct | 11 ms | 384 KB | Output is correct |
23 | Correct | 10 ms | 384 KB | Output is correct |
24 | Correct | 14 ms | 384 KB | Output is correct |
25 | Correct | 9 ms | 384 KB | Output is correct |
26 | Correct | 15 ms | 384 KB | Output is correct |
27 | Correct | 13 ms | 384 KB | Output is correct |
28 | Correct | 1867 ms | 772 KB | Output is correct |
29 | Correct | 1287 ms | 632 KB | Output is correct |
30 | Correct | 1820 ms | 760 KB | Output is correct |
31 | Correct | 1161 ms | 572 KB | Output is correct |
32 | Correct | 1181 ms | 760 KB | Output is correct |
33 | Correct | 1773 ms | 632 KB | Output is correct |
34 | Correct | 1728 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 17 ms | 512 KB | Output is correct |
20 | Correct | 15 ms | 384 KB | Output is correct |
21 | Correct | 14 ms | 384 KB | Output is correct |
22 | Correct | 15 ms | 384 KB | Output is correct |
23 | Correct | 12 ms | 384 KB | Output is correct |
24 | Correct | 8 ms | 384 KB | Output is correct |
25 | Correct | 16 ms | 384 KB | Output is correct |
26 | Correct | 13 ms | 384 KB | Output is correct |
27 | Correct | 17 ms | 384 KB | Output is correct |
28 | Correct | 11 ms | 384 KB | Output is correct |
29 | Correct | 10 ms | 384 KB | Output is correct |
30 | Correct | 14 ms | 384 KB | Output is correct |
31 | Correct | 9 ms | 384 KB | Output is correct |
32 | Correct | 15 ms | 384 KB | Output is correct |
33 | Correct | 13 ms | 384 KB | Output is correct |
34 | Correct | 1867 ms | 772 KB | Output is correct |
35 | Correct | 1287 ms | 632 KB | Output is correct |
36 | Correct | 1820 ms | 760 KB | Output is correct |
37 | Correct | 1161 ms | 572 KB | Output is correct |
38 | Correct | 1181 ms | 760 KB | Output is correct |
39 | Correct | 1773 ms | 632 KB | Output is correct |
40 | Correct | 1728 ms | 592 KB | Output is correct |
41 | Correct | 1811 ms | 736 KB | Output is correct |
42 | Correct | 1059 ms | 516 KB | Output is correct |
43 | Correct | 1683 ms | 672 KB | Output is correct |
44 | Correct | 1797 ms | 600 KB | Output is correct |
45 | Correct | 1425 ms | 888 KB | Output is correct |
46 | Correct | 1217 ms | 932 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 0 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 384 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Execution timed out | 2073 ms | 1092 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |