Submission #1654827


Source Code Expand

import bisect
N = int(input())
src = list(map(int,input().split()))
MAX = 10**5+2

hist = [[] for i in range(MAX)]
for i,a in enumerate(src):
    hist[a].append(i)

dist = 0
first = pos = -1
for arr in hist:
    if len(arr) == 0: continue
    if first < 0:
        first = arr[0]
        pos = arr[-1]
        continue
    i = bisect.bisect_left(arr, pos)
    start = arr[i % len(arr)] # 0 when i==len(arr)
    end = arr[i-1] # -1 when i==0 ... OK
    dist += (end - pos) % N
    pos = end

print(dist // N + 1)

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User prd_xxx
Language Python (3.4.3)
Score 0
Code Size 536 Byte
Status WA
Exec Time 168 ms
Memory 21860 KB

Judge Result

Set Name Sample Small Permutation All
Score / Max Score 0 / 0 0 / 20 0 / 10 0 / 70
Status
AC × 4
AC × 17
WA × 9
AC × 16
WA × 7
AC × 27
WA × 21
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt
Small 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt
Permutation 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 00_example_04.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 20_perm_01.txt, 20_perm_02.txt, 20_perm_03.txt, 20_perm_04.txt, 20_perm_05.txt, 20_perm_06.txt, 20_perm_07.txt, 20_perm_08.txt, 30_hand_01.txt, 30_hand_02.txt, 30_hand_03.txt, 30_hand_04.txt, 30_hand_05.txt, 30_hand_06.txt, 50_rand_01.txt, 50_rand_02.txt, 50_rand_03.txt, 50_rand_04.txt, 50_rand_05.txt, 50_rand_06.txt, 50_rand_07.txt, 50_rand_08.txt, 60_perm_01.txt, 60_perm_02.txt, 60_perm_03.txt, 60_perm_04.txt, 60_perm_05.txt, 60_perm_06.txt, 60_perm_07.txt, 60_perm_08.txt, 70_hand_01.txt, 70_hand_02.txt, 70_hand_03.txt, 70_hand_04.txt, 70_hand_05.txt, 70_hand_06.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 46 ms 10264 KB
00_example_02.txt AC 47 ms 10264 KB
00_example_03.txt AC 49 ms 10264 KB
00_example_04.txt AC 46 ms 10264 KB
10_rand_01.txt WA 45 ms 10264 KB
10_rand_02.txt AC 47 ms 10264 KB
10_rand_03.txt WA 47 ms 10264 KB
10_rand_04.txt AC 47 ms 10264 KB
10_rand_05.txt WA 47 ms 10264 KB
10_rand_06.txt AC 49 ms 10264 KB
10_rand_07.txt AC 46 ms 10264 KB
10_rand_08.txt AC 47 ms 10264 KB
20_perm_01.txt AC 47 ms 10264 KB
20_perm_02.txt AC 46 ms 10264 KB
20_perm_03.txt WA 48 ms 10264 KB
20_perm_04.txt WA 47 ms 10264 KB
20_perm_05.txt AC 49 ms 10200 KB
20_perm_06.txt WA 46 ms 10264 KB
20_perm_07.txt WA 46 ms 10264 KB
20_perm_08.txt WA 48 ms 10264 KB
30_hand_01.txt AC 49 ms 10264 KB
30_hand_02.txt AC 46 ms 10264 KB
30_hand_03.txt AC 47 ms 10288 KB
30_hand_04.txt AC 46 ms 10264 KB
30_hand_05.txt AC 48 ms 10264 KB
30_hand_06.txt WA 46 ms 10200 KB
50_rand_01.txt WA 71 ms 12720 KB
50_rand_02.txt WA 93 ms 15152 KB
50_rand_03.txt WA 94 ms 15264 KB
50_rand_04.txt WA 88 ms 14148 KB
50_rand_05.txt WA 62 ms 11600 KB
50_rand_06.txt WA 48 ms 10288 KB
50_rand_07.txt WA 54 ms 10868 KB
50_rand_08.txt WA 83 ms 14176 KB
60_perm_01.txt AC 97 ms 14328 KB
60_perm_02.txt AC 146 ms 18120 KB
60_perm_03.txt WA 140 ms 18284 KB
60_perm_04.txt WA 119 ms 16420 KB
60_perm_05.txt AC 75 ms 12664 KB
60_perm_06.txt AC 49 ms 10288 KB
60_perm_07.txt AC 59 ms 11380 KB
60_perm_08.txt AC 125 ms 16536 KB
70_hand_01.txt AC 158 ms 21860 KB
70_hand_02.txt AC 168 ms 21860 KB
70_hand_03.txt AC 87 ms 18376 KB
70_hand_04.txt AC 87 ms 18376 KB
70_hand_05.txt WA 161 ms 20196 KB
70_hand_06.txt WA 95 ms 17500 KB