Submission #1137875
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) int N; int A[101010]; //----------------------------------------------------------------- #define INF INT_MAX/2 vector<int> buf[101010]; int main() { cin >> N; rep(i, 0, N) scanf("%d", &A[i]); rep(i, 0, N) buf[A[i]].push_back(i); int ma = 0; rep(i, 0, N) ma = max(ma, A[i]); int ans = 1, idx = -1; rep(i, 0, ma + 1) if (buf[i].size()) { int n = buf[i].size(); int j = upper_bound(buf[i].begin(), buf[i].end(), idx) - buf[i].begin(); if (j == 0) { idx = buf[i][n - 1]; } else { idx = buf[i][j - 1]; if (idx != 0 || i != ma) ans++; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - ディスコ社内ツアー |
User | hamayanhamayan |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 712 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 6144 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] cin >> N; rep(i, 0, N) scanf("%d", &A[i]); ^
Judge Result
Set Name | Sample | Small | Permutation | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 20 / 20 | 10 / 10 | 70 / 70 | ||||||||
Status |
|
|
|
|
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 | 2 ms | 2560 KB |
00_example_02.txt | AC | 2 ms | 2560 KB |
00_example_03.txt | AC | 2 ms | 2560 KB |
00_example_04.txt | AC | 2 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 | 2 ms | 2560 KB |
20_perm_02.txt | AC | 2 ms | 2560 KB |
20_perm_03.txt | AC | 3 ms | 2560 KB |
20_perm_04.txt | AC | 2 ms | 2560 KB |
20_perm_05.txt | AC | 2 ms | 2560 KB |
20_perm_06.txt | AC | 2 ms | 2560 KB |
20_perm_07.txt | AC | 2 ms | 2560 KB |
20_perm_08.txt | AC | 2 ms | 2560 KB |
30_hand_01.txt | AC | 2 ms | 2560 KB |
30_hand_02.txt | AC | 2 ms | 2560 KB |
30_hand_03.txt | AC | 2 ms | 2560 KB |
30_hand_04.txt | AC | 2 ms | 2560 KB |
30_hand_05.txt | AC | 3 ms | 2560 KB |
30_hand_06.txt | AC | 2 ms | 2560 KB |
50_rand_01.txt | AC | 8 ms | 3072 KB |
50_rand_02.txt | AC | 12 ms | 3584 KB |
50_rand_03.txt | AC | 12 ms | 3712 KB |
50_rand_04.txt | AC | 10 ms | 3456 KB |
50_rand_05.txt | AC | 6 ms | 2944 KB |
50_rand_06.txt | AC | 3 ms | 2688 KB |
50_rand_07.txt | AC | 4 ms | 2816 KB |
50_rand_08.txt | AC | 11 ms | 3456 KB |
60_perm_01.txt | AC | 8 ms | 3840 KB |
60_perm_02.txt | AC | 14 ms | 4992 KB |
60_perm_03.txt | AC | 14 ms | 4992 KB |
60_perm_04.txt | AC | 11 ms | 4480 KB |
60_perm_05.txt | AC | 6 ms | 3328 KB |
60_perm_06.txt | AC | 2 ms | 2688 KB |
60_perm_07.txt | AC | 4 ms | 2944 KB |
60_perm_08.txt | AC | 12 ms | 4480 KB |
70_hand_01.txt | AC | 17 ms | 6144 KB |
70_hand_02.txt | AC | 17 ms | 6144 KB |
70_hand_03.txt | AC | 11 ms | 3580 KB |
70_hand_04.txt | AC | 11 ms | 3580 KB |
70_hand_05.txt | AC | 21 ms | 4992 KB |
70_hand_06.txt | AC | 12 ms | 3584 KB |