Submission #828840

# Submission time Handle Problem Language Result Execution time Memory
828840 2023-08-17T17:17:01 Z cgiosy 격자 보존하기 (GA9_preserve) C++17
100 / 100
20 ms 1676 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int M, N, K;
	cin>>M>>N>>K;
	int A[N+1], x=0;
	for(int i=0, y; i<N; i++) cin>>y, A[i]=y-x-1, x=y;
	A[N]=M-x;
	sort(A+1, A+N);
	auto f=[&](int t) {
		int n=max(0, 2*N-K-t+1>>1), m=M-N;
		for(int i=1; i<=n; i++) m-=A[i];
		return m;
	};
	cout<<max({f(0), f(1)-min(A[0], A[N]), f(2)-A[0]-A[N]})<<'\n';
}

Compilation message

preserve.cpp: In lambda function:
preserve.cpp:13:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |   int n=max(0, 2*N-K-t+1>>1), m=M-N;
      |                ~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 320 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 324 KB Output is correct
16 Correct 0 ms 328 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory 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 1 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 1 ms 316 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1676 KB Output is correct
2 Correct 14 ms 1620 KB Output is correct
3 Correct 14 ms 1588 KB Output is correct
4 Correct 14 ms 1584 KB Output is correct
5 Correct 20 ms 1584 KB Output is correct
6 Correct 18 ms 1620 KB Output is correct
7 Correct 14 ms 1580 KB Output is correct
8 Correct 14 ms 1668 KB Output is correct
9 Correct 7 ms 980 KB Output is correct
10 Correct 4 ms 724 KB Output is correct
11 Correct 13 ms 1612 KB Output is correct
12 Correct 13 ms 1620 KB Output is correct
13 Correct 14 ms 1492 KB Output is correct
14 Correct 12 ms 1492 KB Output is correct
15 Correct 14 ms 1588 KB Output is correct
16 Correct 13 ms 1620 KB Output is correct
17 Correct 13 ms 1580 KB Output is correct
18 Correct 13 ms 1620 KB Output is correct
19 Correct 13 ms 1612 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 13 ms 1492 KB Output is correct
23 Correct 14 ms 1584 KB Output is correct
24 Correct 17 ms 1456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1620 KB Output is correct
2 Correct 14 ms 1612 KB Output is correct
3 Correct 14 ms 1612 KB Output is correct
4 Correct 14 ms 1620 KB Output is correct
5 Correct 14 ms 1592 KB Output is correct
6 Correct 14 ms 1620 KB Output is correct
7 Correct 14 ms 1588 KB Output is correct
8 Correct 14 ms 1616 KB Output is correct
9 Correct 7 ms 980 KB Output is correct
10 Correct 4 ms 728 KB Output is correct
11 Correct 10 ms 1272 KB Output is correct
12 Correct 11 ms 1236 KB Output is correct
13 Correct 13 ms 1396 KB Output is correct
14 Correct 11 ms 1364 KB Output is correct
15 Correct 9 ms 1236 KB Output is correct
16 Correct 10 ms 1280 KB Output is correct
17 Correct 12 ms 1492 KB Output is correct
18 Correct 10 ms 1364 KB Output is correct
19 Correct 11 ms 1360 KB Output is correct
20 Correct 11 ms 1428 KB Output is correct