Submission #3464829


Source Code Expand

from bisect import bisect
from collections import defaultdict

N = int(input())
A = list(map(int,input().split()))

idxs = defaultdict(lambda: [])
for i,a in enumerate(A):
    idxs[a].append(i)

ans = 1
now = -1
for _,arr in sorted(idxs.items()):
    i = bisect(arr, now)
    if i == 0:
        now = arr[-1]
    else:
        ans += 1
        now = arr[i-1]

if now == 0:
    ans -= 1

print(ans)

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User prd_xxx
Language Python (3.4.3)
Score 100
Code Size 420 Byte
Status AC
Exec Time 178 ms
Memory 34780 KB

Judge Result

Set Name Sample Small Permutation All
Score / Max Score 0 / 0 20 / 20 10 / 10 70 / 70
Status
AC × 4
AC × 26
AC × 23
AC × 48
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 20 ms 3316 KB
00_example_02.txt AC 20 ms 3316 KB
00_example_03.txt AC 21 ms 3316 KB
00_example_04.txt AC 21 ms 3316 KB
10_rand_01.txt AC 21 ms 3316 KB
10_rand_02.txt AC 21 ms 3316 KB
10_rand_03.txt AC 21 ms 3316 KB
10_rand_04.txt AC 21 ms 3316 KB
10_rand_05.txt AC 21 ms 3316 KB
10_rand_06.txt AC 21 ms 3316 KB
10_rand_07.txt AC 21 ms 3316 KB
10_rand_08.txt AC 21 ms 3316 KB
20_perm_01.txt AC 21 ms 3316 KB
20_perm_02.txt AC 21 ms 3316 KB
20_perm_03.txt AC 21 ms 3316 KB
20_perm_04.txt AC 21 ms 3316 KB
20_perm_05.txt AC 21 ms 3316 KB
20_perm_06.txt AC 21 ms 3316 KB
20_perm_07.txt AC 21 ms 3316 KB
20_perm_08.txt AC 21 ms 3316 KB
30_hand_01.txt AC 21 ms 3316 KB
30_hand_02.txt AC 21 ms 3316 KB
30_hand_03.txt AC 21 ms 3316 KB
30_hand_04.txt AC 21 ms 3316 KB
30_hand_05.txt AC 21 ms 3316 KB
30_hand_06.txt AC 21 ms 3316 KB
50_rand_01.txt AC 50 ms 7388 KB
50_rand_02.txt AC 82 ms 11440 KB
50_rand_03.txt AC 80 ms 11420 KB
50_rand_04.txt AC 69 ms 10176 KB
50_rand_05.txt AC 36 ms 5448 KB
50_rand_06.txt AC 21 ms 3316 KB
50_rand_07.txt AC 28 ms 4468 KB
50_rand_08.txt AC 67 ms 9948 KB
60_perm_01.txt AC 80 ms 13836 KB
60_perm_02.txt AC 150 ms 23488 KB
60_perm_03.txt AC 155 ms 23744 KB
60_perm_04.txt AC 123 ms 22044 KB
60_perm_05.txt AC 55 ms 9488 KB
60_perm_06.txt AC 21 ms 3316 KB
60_perm_07.txt AC 37 ms 6320 KB
60_perm_08.txt AC 125 ms 20220 KB
70_hand_01.txt AC 170 ms 34780 KB
70_hand_02.txt AC 178 ms 34780 KB
70_hand_03.txt AC 64 ms 14316 KB
70_hand_04.txt AC 61 ms 14316 KB
70_hand_05.txt AC 168 ms 24928 KB
70_hand_06.txt AC 69 ms 13556 KB