Submission #47871

# Submission time Handle Problem Language Result Execution time Memory
47871 2018-05-08T10:25:53 Z leejseo 격자 보존하기 (GA9_preserve) Python 2
100 / 100
192 ms 26320 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(min(d/2, len(inter))):
        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(min(d/2, len(inter1))):
        ans1 += inter1[i]
    inter[0] += inter.pop()
    inter.sort()
    inter.reverse()
    for i in range(min(d/2, len(inter))):
        ans2 += inter[i]
    print max(ans1, ans2)
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2936 KB Output is correct
2 Correct 13 ms 3068 KB Output is correct
3 Correct 13 ms 3144 KB Output is correct
4 Correct 13 ms 3144 KB Output is correct
5 Correct 13 ms 3144 KB Output is correct
6 Correct 12 ms 3200 KB Output is correct
7 Correct 13 ms 3200 KB Output is correct
8 Correct 13 ms 3200 KB Output is correct
9 Correct 12 ms 3200 KB Output is correct
10 Correct 13 ms 3200 KB Output is correct
11 Correct 13 ms 3360 KB Output is correct
12 Correct 13 ms 3360 KB Output is correct
13 Correct 12 ms 3360 KB Output is correct
14 Correct 13 ms 3360 KB Output is correct
15 Correct 12 ms 3360 KB Output is correct
16 Correct 13 ms 3360 KB Output is correct
17 Correct 13 ms 3360 KB Output is correct
18 Correct 13 ms 3360 KB Output is correct
19 Correct 13 ms 3360 KB Output is correct
20 Correct 13 ms 3360 KB Output is correct
21 Correct 13 ms 3360 KB Output is correct
22 Correct 13 ms 3456 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 12 ms 3456 KB Output is correct
25 Correct 13 ms 3456 KB Output is correct
26 Correct 12 ms 3456 KB Output is correct
27 Correct 12 ms 3580 KB Output is correct
28 Correct 13 ms 3580 KB Output is correct
29 Correct 12 ms 3580 KB Output is correct
30 Correct 13 ms 3580 KB Output is correct
31 Correct 13 ms 3580 KB Output is correct
32 Correct 17 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3580 KB Output is correct
2 Correct 13 ms 3580 KB Output is correct
3 Correct 13 ms 3580 KB Output is correct
4 Correct 15 ms 3580 KB Output is correct
5 Correct 13 ms 3580 KB Output is correct
6 Correct 12 ms 3580 KB Output is correct
7 Correct 13 ms 3580 KB Output is correct
8 Correct 13 ms 3580 KB Output is correct
9 Correct 14 ms 3580 KB Output is correct
10 Correct 13 ms 3580 KB Output is correct
11 Correct 13 ms 3580 KB Output is correct
12 Correct 13 ms 3580 KB Output is correct
13 Correct 13 ms 3580 KB Output is correct
14 Correct 13 ms 3580 KB Output is correct
15 Correct 13 ms 3580 KB Output is correct
16 Correct 13 ms 3580 KB Output is correct
17 Correct 13 ms 3580 KB Output is correct
18 Correct 13 ms 3580 KB Output is correct
19 Correct 13 ms 3580 KB Output is correct
20 Correct 13 ms 3580 KB Output is correct
21 Correct 13 ms 3580 KB Output is correct
22 Correct 13 ms 3580 KB Output is correct
23 Correct 13 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3580 KB Output is correct
2 Correct 13 ms 3580 KB Output is correct
3 Correct 13 ms 3580 KB Output is correct
4 Correct 14 ms 3580 KB Output is correct
5 Correct 14 ms 3580 KB Output is correct
6 Correct 14 ms 3580 KB Output is correct
7 Correct 14 ms 3580 KB Output is correct
8 Correct 13 ms 3580 KB Output is correct
9 Correct 14 ms 3580 KB Output is correct
10 Correct 12 ms 3580 KB Output is correct
11 Correct 14 ms 3624 KB Output is correct
12 Correct 14 ms 3624 KB Output is correct
13 Correct 13 ms 3624 KB Output is correct
14 Correct 13 ms 3624 KB Output is correct
15 Correct 13 ms 3624 KB Output is correct
16 Correct 13 ms 3624 KB Output is correct
17 Correct 14 ms 3624 KB Output is correct
18 Correct 13 ms 3624 KB Output is correct
19 Correct 13 ms 3624 KB Output is correct
20 Correct 14 ms 3624 KB Output is correct
21 Correct 14 ms 3624 KB Output is correct
22 Correct 14 ms 3624 KB Output is correct
23 Correct 12 ms 3624 KB Output is correct
24 Correct 13 ms 3624 KB Output is correct
25 Correct 12 ms 3624 KB Output is correct
26 Correct 18 ms 3624 KB Output is correct
27 Correct 13 ms 3624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12176 KB Output is correct
2 Correct 125 ms 12176 KB Output is correct
3 Correct 124 ms 12176 KB Output is correct
4 Correct 124 ms 12176 KB Output is correct
5 Correct 130 ms 12176 KB Output is correct
6 Correct 124 ms 12176 KB Output is correct
7 Correct 93 ms 12176 KB Output is correct
8 Correct 166 ms 12176 KB Output is correct
9 Correct 66 ms 12176 KB Output is correct
10 Correct 45 ms 12176 KB Output is correct
11 Correct 130 ms 12176 KB Output is correct
12 Correct 123 ms 12176 KB Output is correct
13 Correct 157 ms 12176 KB Output is correct
14 Correct 120 ms 12176 KB Output is correct
15 Correct 125 ms 12176 KB Output is correct
16 Correct 158 ms 12180 KB Output is correct
17 Correct 124 ms 12180 KB Output is correct
18 Correct 159 ms 12180 KB Output is correct
19 Correct 171 ms 12180 KB Output is correct
20 Correct 15 ms 12180 KB Output is correct
21 Correct 14 ms 12180 KB Output is correct
22 Correct 125 ms 12180 KB Output is correct
23 Correct 128 ms 12180 KB Output is correct
24 Correct 155 ms 12180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 192 ms 12180 KB Output is correct
2 Correct 145 ms 13092 KB Output is correct
3 Correct 139 ms 14100 KB Output is correct
4 Correct 127 ms 15064 KB Output is correct
5 Correct 132 ms 16040 KB Output is correct
6 Correct 131 ms 17008 KB Output is correct
7 Correct 133 ms 17976 KB Output is correct
8 Correct 129 ms 18944 KB Output is correct
9 Correct 67 ms 18944 KB Output is correct
10 Correct 44 ms 18944 KB Output is correct
11 Correct 90 ms 18944 KB Output is correct
12 Correct 101 ms 19196 KB Output is correct
13 Correct 135 ms 20020 KB Output is correct
14 Correct 152 ms 20788 KB Output is correct
15 Correct 94 ms 21512 KB Output is correct
16 Correct 108 ms 22796 KB Output is correct
17 Correct 133 ms 24296 KB Output is correct
18 Correct 125 ms 24700 KB Output is correct
19 Correct 129 ms 24700 KB Output is correct
20 Correct 170 ms 26320 KB Output is correct