답안 #594633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594633 2022-07-12T18:34:58 Z penguinhacker Safety (NOI18_safety) C++17
66 / 100
2000 ms 1732 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

const int mxN=2e5;
int n, h, a[mxN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> h;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	ll ans=0;
	vector<ll> v={a[0], a[0]};
	for (int i=1; i<n; ++i) {
		for (int j=0; j<i; ++j)
			v[j]-=h, v[j+i]+=h;
		if (a[i]<v[i-1])
			ans+=v[i-1]-a[i];
		if (a[i]>v[i])
			ans+=a[i]-v[i];
		v.push_back(a[i]);
		v.push_back(a[i]);
		sort(v.begin(), v.end());
	}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 224 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2059 ms 1732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 9 ms 348 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 9 ms 348 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
20 Correct 5 ms 328 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 5 ms 348 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 6 ms 336 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 10 ms 340 KB Output is correct
14 Correct 9 ms 348 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 5 ms 340 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 7 ms 348 KB Output is correct
20 Correct 5 ms 328 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 5 ms 348 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 6 ms 336 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 7 ms 340 KB Output is correct
28 Correct 1002 ms 684 KB Output is correct
29 Correct 704 ms 480 KB Output is correct
30 Correct 918 ms 668 KB Output is correct
31 Correct 637 ms 404 KB Output is correct
32 Correct 615 ms 484 KB Output is correct
33 Correct 922 ms 564 KB Output is correct
34 Correct 893 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 10 ms 340 KB Output is correct
20 Correct 9 ms 348 KB Output is correct
21 Correct 6 ms 340 KB Output is correct
22 Correct 6 ms 332 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 7 ms 348 KB Output is correct
26 Correct 5 ms 328 KB Output is correct
27 Correct 6 ms 340 KB Output is correct
28 Correct 5 ms 348 KB Output is correct
29 Correct 3 ms 340 KB Output is correct
30 Correct 6 ms 336 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Correct 7 ms 340 KB Output is correct
34 Correct 1002 ms 684 KB Output is correct
35 Correct 704 ms 480 KB Output is correct
36 Correct 918 ms 668 KB Output is correct
37 Correct 637 ms 404 KB Output is correct
38 Correct 615 ms 484 KB Output is correct
39 Correct 922 ms 564 KB Output is correct
40 Correct 893 ms 668 KB Output is correct
41 Correct 985 ms 616 KB Output is correct
42 Correct 576 ms 544 KB Output is correct
43 Correct 845 ms 952 KB Output is correct
44 Correct 900 ms 576 KB Output is correct
45 Correct 731 ms 748 KB Output is correct
46 Correct 670 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 224 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Execution timed out 2059 ms 1732 KB Time limit exceeded
20 Halted 0 ms 0 KB -