# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101864 | 2019-03-20T15:06:20 Z | rocketninja7 | Safety (NOI18_safety) | C++14 | 405 ms | 20600 KB |
#include <cstdio> #include <vector> #include <set> using namespace std; int main(){ int N; long long int H; scanf("%d%lld", &N, &H); long long int S[N+1]; for(int i=1;i<N+1;i++){ scanf("%lld", &S[i]); } multiset<long long int> pointsL; multiset<long long int> pointsR; pointsL.insert(-1); pointsR.insert(1000000001); long long int ans=0; for(int i=1;i<N+1;i++){ if(S[i]<*(--pointsL.end())-H*i){ pointsL.insert(S[i]+H*i); pointsL.insert(S[i]+H*i); pointsR.insert((*(--pointsL.end()))-2*H*i); pointsL.erase(--pointsL.end()); ans+=(*pointsR.begin())+H*i-S[i]; } else if(S[i]>*pointsR.begin()+H*i){ pointsR.insert(S[i]-H*i); pointsR.insert(S[i]-H*i); pointsL.insert((*pointsR.begin())+2*H*i); pointsR.erase(pointsR.begin()); ans+=S[i]-(*(--pointsL.end()))+H*i; } else{ pointsL.insert(S[i]+H*i); pointsR.insert(S[i]-H*i); } } printf("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 352 KB | Output is correct |
5 | Correct | 2 ms | 252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 200 ms | 13672 KB | Output is correct |
2 | Correct | 405 ms | 19448 KB | Output is correct |
3 | Correct | 318 ms | 20200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 352 KB | Output is correct |
12 | Correct | 2 ms | 252 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 276 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 352 KB | Output is correct |
12 | Correct | 2 ms | 252 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 276 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 8 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 380 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 352 KB | Output is correct |
12 | Correct | 2 ms | 252 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 276 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 380 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 8 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 380 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 380 KB | Output is correct |
28 | Correct | 5 ms | 888 KB | Output is correct |
29 | Correct | 5 ms | 760 KB | Output is correct |
30 | Correct | 4 ms | 888 KB | Output is correct |
31 | Correct | 4 ms | 760 KB | Output is correct |
32 | Correct | 4 ms | 760 KB | Output is correct |
33 | Correct | 5 ms | 888 KB | Output is correct |
34 | Correct | 4 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 352 KB | Output is correct |
12 | Correct | 2 ms | 252 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 276 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 380 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 380 KB | Output is correct |
28 | Correct | 3 ms | 376 KB | Output is correct |
29 | Correct | 8 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 380 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 380 KB | Output is correct |
34 | Correct | 5 ms | 888 KB | Output is correct |
35 | Correct | 5 ms | 760 KB | Output is correct |
36 | Correct | 4 ms | 888 KB | Output is correct |
37 | Correct | 4 ms | 760 KB | Output is correct |
38 | Correct | 4 ms | 760 KB | Output is correct |
39 | Correct | 5 ms | 888 KB | Output is correct |
40 | Correct | 4 ms | 760 KB | Output is correct |
41 | Correct | 7 ms | 740 KB | Output is correct |
42 | Correct | 5 ms | 632 KB | Output is correct |
43 | Correct | 5 ms | 764 KB | Output is correct |
44 | Correct | 5 ms | 760 KB | Output is correct |
45 | Correct | 4 ms | 760 KB | Output is correct |
46 | Correct | 4 ms | 764 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 352 KB | Output is correct |
12 | Correct | 2 ms | 252 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 200 ms | 13672 KB | Output is correct |
20 | Correct | 405 ms | 19448 KB | Output is correct |
21 | Correct | 318 ms | 20200 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 276 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 380 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 380 KB | Output is correct |
31 | Correct | 3 ms | 376 KB | Output is correct |
32 | Correct | 8 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 380 KB | Output is correct |
35 | Correct | 2 ms | 376 KB | Output is correct |
36 | Correct | 2 ms | 380 KB | Output is correct |
37 | Correct | 5 ms | 888 KB | Output is correct |
38 | Correct | 5 ms | 760 KB | Output is correct |
39 | Correct | 4 ms | 888 KB | Output is correct |
40 | Correct | 4 ms | 760 KB | Output is correct |
41 | Correct | 4 ms | 760 KB | Output is correct |
42 | Correct | 5 ms | 888 KB | Output is correct |
43 | Correct | 4 ms | 760 KB | Output is correct |
44 | Correct | 7 ms | 740 KB | Output is correct |
45 | Correct | 5 ms | 632 KB | Output is correct |
46 | Correct | 5 ms | 764 KB | Output is correct |
47 | Correct | 5 ms | 760 KB | Output is correct |
48 | Correct | 4 ms | 760 KB | Output is correct |
49 | Correct | 4 ms | 764 KB | Output is correct |
50 | Correct | 355 ms | 20600 KB | Output is correct |
51 | Correct | 284 ms | 17224 KB | Output is correct |
52 | Correct | 147 ms | 16620 KB | Output is correct |
53 | Correct | 162 ms | 19224 KB | Output is correct |
54 | Correct | 147 ms | 19796 KB | Output is correct |
55 | Correct | 136 ms | 16824 KB | Output is correct |
56 | Correct | 160 ms | 18468 KB | Output is correct |
57 | Correct | 139 ms | 16888 KB | Output is correct |
58 | Correct | 132 ms | 14848 KB | Output is correct |
59 | Correct | 156 ms | 18720 KB | Output is correct |