Submission #1655314


Source Code Expand

#include <iostream>
#include <vector>
#include <algorithm>

int N;
std::vector<int> A[100001];

int main(){
    std::cin >> N;
    int max = 0;
    for(int i=0; i<N; ++i){
        int a;
        std::cin >> a;
        A[a].push_back(i);
        max = std::max(max,a);
    }

    int ans = 1, p = -1;
    for (int i = 1; i <= max; i++) {
		if (A[i].empty()) continue;
        int itr = upper_bound(A[i].begin(), A[i].end(), p) - A[i].begin();
        
		if (itr == 0) {
			p = *(A[i].end()-1);
			continue;
        }
		p = A[i][itr - 1];
		if (p != 0 || i != max){
            ans++;
        }
	}
	std::cout << ans << std::endl;
}

Submission Info

Submission Time
Task B - ディスコ社内ツアー
User b1464296
Language C++14 (GCC 5.4.1)
Score 100
Code Size 661 Byte
Status AC
Exec Time 48 ms
Memory 5760 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 3 ms 2560 KB
00_example_02.txt AC 3 ms 2560 KB
00_example_03.txt AC 3 ms 2560 KB
00_example_04.txt AC 3 ms 2560 KB
10_rand_01.txt AC 3 ms 2560 KB
10_rand_02.txt AC 3 ms 2560 KB
10_rand_03.txt AC 3 ms 2560 KB
10_rand_04.txt AC 3 ms 2560 KB
10_rand_05.txt AC 3 ms 2560 KB
10_rand_06.txt AC 3 ms 2560 KB
10_rand_07.txt AC 3 ms 2560 KB
10_rand_08.txt AC 3 ms 2560 KB
20_perm_01.txt AC 3 ms 2560 KB
20_perm_02.txt AC 3 ms 2560 KB
20_perm_03.txt AC 3 ms 2560 KB
20_perm_04.txt AC 3 ms 2560 KB
20_perm_05.txt AC 3 ms 2560 KB
20_perm_06.txt AC 3 ms 2560 KB
20_perm_07.txt AC 3 ms 2560 KB
20_perm_08.txt AC 3 ms 2560 KB
30_hand_01.txt AC 3 ms 2560 KB
30_hand_02.txt AC 3 ms 2560 KB
30_hand_03.txt AC 3 ms 2560 KB
30_hand_04.txt AC 3 ms 2560 KB
30_hand_05.txt AC 3 ms 2560 KB
30_hand_06.txt AC 3 ms 2560 KB
50_rand_01.txt AC 14 ms 2944 KB
50_rand_02.txt AC 24 ms 3328 KB
50_rand_03.txt AC 25 ms 3328 KB
50_rand_04.txt AC 21 ms 3200 KB
50_rand_05.txt AC 10 ms 2816 KB
50_rand_06.txt AC 3 ms 2560 KB
50_rand_07.txt AC 6 ms 2688 KB
50_rand_08.txt AC 21 ms 3200 KB
60_perm_01.txt AC 17 ms 3712 KB
60_perm_02.txt AC 31 ms 4736 KB
60_perm_03.txt AC 34 ms 4736 KB
60_perm_04.txt AC 25 ms 4224 KB
60_perm_05.txt AC 11 ms 3328 KB
60_perm_06.txt AC 3 ms 2560 KB
60_perm_07.txt AC 7 ms 2944 KB
60_perm_08.txt AC 25 ms 4352 KB
70_hand_01.txt AC 43 ms 5760 KB
70_hand_02.txt AC 44 ms 5760 KB
70_hand_03.txt AC 29 ms 3196 KB
70_hand_04.txt AC 29 ms 3196 KB
70_hand_05.txt AC 48 ms 4608 KB
70_hand_06.txt AC 30 ms 3200 KB