# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
47870 |
2018-05-08T10:23:44 Z |
leejseo |
격자 보존하기 (GA9_preserve) |
Python 2 |
|
203 ms |
12956 KB |
range = xrange
n, k, d = map(int, raw_input().split())
p = map(int, raw_input().split())
inter = [0]*(k+1)
for i in range(1, k):
inter[i] = p[i] - p[i-1] - 1
inter[0] = p[0] - 1
inter[-1] = n - p[-1]
if d == 1 :
print max(inter[0], inter[-1])
elif d == 2 :
print max(max(inter), inter[0] + inter[-1])
elif d % 2 == 0:
inter[0] += inter.pop()
inter.sort()
inter.reverse()
ans = 0
for i in range(d/2):
ans += inter[i]
print ans
else:
ans1, ans2 = 0, 0
ans1 = max(inter[0], inter[-1])
inter1 = inter[1:len(inter)-1]
inter1.sort()
inter1.reverse()
for i in range(d/2):
ans1 += inter1[i]
inter[0] += inter.pop()
inter.sort()
inter.reverse()
for i in range(d/2):
ans2 += inter[i]
print max(ans1, ans2)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
3052 KB |
Output is correct |
2 |
Correct |
16 ms |
3052 KB |
Output is correct |
3 |
Correct |
14 ms |
3200 KB |
Output is correct |
4 |
Correct |
15 ms |
3052 KB |
Output is correct |
5 |
Correct |
12 ms |
3200 KB |
Output is correct |
6 |
Correct |
12 ms |
3052 KB |
Output is correct |
7 |
Correct |
12 ms |
3052 KB |
Output is correct |
8 |
Runtime error |
13 ms |
3180 KB |
Execution failed because the return code was nonzero |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
3052 KB |
Output is correct |
2 |
Correct |
14 ms |
3052 KB |
Output is correct |
3 |
Correct |
15 ms |
3052 KB |
Output is correct |
4 |
Correct |
15 ms |
3052 KB |
Output is correct |
5 |
Correct |
12 ms |
3180 KB |
Output is correct |
6 |
Correct |
15 ms |
3052 KB |
Output is correct |
7 |
Correct |
11 ms |
3052 KB |
Output is correct |
8 |
Correct |
11 ms |
3052 KB |
Output is correct |
9 |
Correct |
12 ms |
3052 KB |
Output is correct |
10 |
Correct |
11 ms |
3052 KB |
Output is correct |
11 |
Correct |
12 ms |
3052 KB |
Output is correct |
12 |
Correct |
12 ms |
3180 KB |
Output is correct |
13 |
Correct |
15 ms |
3180 KB |
Output is correct |
14 |
Correct |
12 ms |
3180 KB |
Output is correct |
15 |
Correct |
14 ms |
3052 KB |
Output is correct |
16 |
Correct |
14 ms |
3052 KB |
Output is correct |
17 |
Correct |
12 ms |
3052 KB |
Output is correct |
18 |
Correct |
12 ms |
3052 KB |
Output is correct |
19 |
Correct |
15 ms |
3052 KB |
Output is correct |
20 |
Correct |
12 ms |
3052 KB |
Output is correct |
21 |
Correct |
12 ms |
3052 KB |
Output is correct |
22 |
Correct |
16 ms |
3052 KB |
Output is correct |
23 |
Correct |
12 ms |
3180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
3180 KB |
Output is correct |
2 |
Correct |
13 ms |
3180 KB |
Output is correct |
3 |
Correct |
16 ms |
3180 KB |
Output is correct |
4 |
Correct |
15 ms |
3180 KB |
Output is correct |
5 |
Correct |
13 ms |
3180 KB |
Output is correct |
6 |
Correct |
13 ms |
3052 KB |
Output is correct |
7 |
Correct |
14 ms |
3308 KB |
Output is correct |
8 |
Correct |
12 ms |
3052 KB |
Output is correct |
9 |
Correct |
12 ms |
3052 KB |
Output is correct |
10 |
Correct |
15 ms |
3052 KB |
Output is correct |
11 |
Correct |
13 ms |
3180 KB |
Output is correct |
12 |
Correct |
16 ms |
3180 KB |
Output is correct |
13 |
Correct |
13 ms |
3180 KB |
Output is correct |
14 |
Correct |
12 ms |
3052 KB |
Output is correct |
15 |
Correct |
12 ms |
3052 KB |
Output is correct |
16 |
Correct |
12 ms |
3052 KB |
Output is correct |
17 |
Correct |
16 ms |
3200 KB |
Output is correct |
18 |
Correct |
14 ms |
3308 KB |
Output is correct |
19 |
Correct |
14 ms |
3328 KB |
Output is correct |
20 |
Correct |
15 ms |
3052 KB |
Output is correct |
21 |
Correct |
14 ms |
3328 KB |
Output is correct |
22 |
Correct |
17 ms |
3180 KB |
Output is correct |
23 |
Correct |
12 ms |
3200 KB |
Output is correct |
24 |
Correct |
14 ms |
3052 KB |
Output is correct |
25 |
Correct |
12 ms |
3052 KB |
Output is correct |
26 |
Correct |
12 ms |
3052 KB |
Output is correct |
27 |
Correct |
12 ms |
3052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
12808 KB |
Output is correct |
2 |
Correct |
144 ms |
12808 KB |
Output is correct |
3 |
Correct |
135 ms |
12808 KB |
Output is correct |
4 |
Correct |
130 ms |
12684 KB |
Output is correct |
5 |
Correct |
137 ms |
12808 KB |
Output is correct |
6 |
Correct |
189 ms |
12808 KB |
Output is correct |
7 |
Correct |
99 ms |
12956 KB |
Output is correct |
8 |
Correct |
200 ms |
12808 KB |
Output is correct |
9 |
Correct |
71 ms |
8064 KB |
Output is correct |
10 |
Correct |
44 ms |
5932 KB |
Output is correct |
11 |
Correct |
144 ms |
12468 KB |
Output is correct |
12 |
Correct |
130 ms |
12412 KB |
Output is correct |
13 |
Correct |
174 ms |
12344 KB |
Output is correct |
14 |
Correct |
124 ms |
12508 KB |
Output is correct |
15 |
Correct |
133 ms |
12576 KB |
Output is correct |
16 |
Correct |
203 ms |
12700 KB |
Output is correct |
17 |
Correct |
120 ms |
12372 KB |
Output is correct |
18 |
Correct |
191 ms |
12344 KB |
Output is correct |
19 |
Correct |
200 ms |
12340 KB |
Output is correct |
20 |
Correct |
16 ms |
3180 KB |
Output is correct |
21 |
Correct |
15 ms |
3052 KB |
Output is correct |
22 |
Correct |
125 ms |
12236 KB |
Output is correct |
23 |
Correct |
136 ms |
12568 KB |
Output is correct |
24 |
Correct |
166 ms |
12420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
148 ms |
12808 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |