Submission #1655677
Source Code Expand
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<functional> #include<string> using namespace std; typedef pair<int, int> P; typedef pair<int, P> PP; typedef long long ll; int n; vector<P> a; int main() { cin >> n; int ai; for (int i = 0; i < n; i++) { cin >> ai; a.push_back(P(ai, i + 1)); } sort(a.begin(), a.end()); int ans = 1; int i = 1; int cur_r = a[0].second; while (i < a.size()) { if (a[i].first == a[i - 1].first) { cur_r = a[i].second; i++; } else { if (a[i].second > cur_r) { cur_r = a[i].second; i++; } else { int k = i; int ope = 0; while (k<a.size()&&a[k].first == a[i].first) { if (a[k].second > cur_r) { ope = 1; cur_r = a[k - 1].second; break; } else k++; } if (ope == 0) { ans++; cur_r = a[k - 1].second; i = k; } else { ans++; while (k<a.size()) { if (a[k].first != a[k - 1].first) { i = k; break; } else k++; } i = k; } } } } if (cur_r== 1)ans--; cout << ans << endl; /* int i=1; while (i < a.size()) { if (a[i].first > a[i - 1].first) { if (a[i].second > a[i-1].second)i++; else { while (1) { if (a[i + 1].first > a[i].first)ans++; else { } } } } if (a[i].second > a[i - 1].second) { if (a[i].first > a[i - 1].first); } } for (int i = 1; i < a.size(); i++) { if (a[i].second < a[i - 1].second)ans++; } if (a[a.size() - 1].second == 1)ans--; */ return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - ディスコ社内ツアー |
User | kns330 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 1657 Byte |
Status | AC |
Exec Time | 45 ms |
Memory | 1400 KB |
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 | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 1 ms | 256 KB |
00_example_04.txt | AC | 1 ms | 256 KB |
10_rand_01.txt | AC | 1 ms | 256 KB |
10_rand_02.txt | AC | 1 ms | 256 KB |
10_rand_03.txt | AC | 1 ms | 256 KB |
10_rand_04.txt | AC | 1 ms | 256 KB |
10_rand_05.txt | AC | 1 ms | 256 KB |
10_rand_06.txt | AC | 1 ms | 256 KB |
10_rand_07.txt | AC | 1 ms | 256 KB |
10_rand_08.txt | AC | 1 ms | 256 KB |
20_perm_01.txt | AC | 1 ms | 256 KB |
20_perm_02.txt | AC | 1 ms | 256 KB |
20_perm_03.txt | AC | 1 ms | 256 KB |
20_perm_04.txt | AC | 1 ms | 256 KB |
20_perm_05.txt | AC | 1 ms | 256 KB |
20_perm_06.txt | AC | 1 ms | 256 KB |
20_perm_07.txt | AC | 1 ms | 256 KB |
20_perm_08.txt | AC | 1 ms | 256 KB |
30_hand_01.txt | AC | 1 ms | 256 KB |
30_hand_02.txt | AC | 1 ms | 256 KB |
30_hand_03.txt | AC | 1 ms | 256 KB |
30_hand_04.txt | AC | 1 ms | 256 KB |
30_hand_05.txt | AC | 1 ms | 256 KB |
30_hand_06.txt | AC | 1 ms | 256 KB |
50_rand_01.txt | AC | 14 ms | 892 KB |
50_rand_02.txt | AC | 26 ms | 1400 KB |
50_rand_03.txt | AC | 26 ms | 1400 KB |
50_rand_04.txt | AC | 20 ms | 892 KB |
50_rand_05.txt | AC | 9 ms | 640 KB |
50_rand_06.txt | AC | 1 ms | 256 KB |
50_rand_07.txt | AC | 5 ms | 512 KB |
50_rand_08.txt | AC | 21 ms | 892 KB |
60_perm_01.txt | AC | 16 ms | 892 KB |
60_perm_02.txt | AC | 30 ms | 1400 KB |
60_perm_03.txt | AC | 30 ms | 1400 KB |
60_perm_04.txt | AC | 24 ms | 892 KB |
60_perm_05.txt | AC | 10 ms | 640 KB |
60_perm_06.txt | AC | 1 ms | 256 KB |
60_perm_07.txt | AC | 5 ms | 512 KB |
60_perm_08.txt | AC | 25 ms | 892 KB |
70_hand_01.txt | AC | 39 ms | 1400 KB |
70_hand_02.txt | AC | 39 ms | 1400 KB |
70_hand_03.txt | AC | 31 ms | 1400 KB |
70_hand_04.txt | AC | 30 ms | 1400 KB |
70_hand_05.txt | AC | 45 ms | 1400 KB |
70_hand_06.txt | AC | 37 ms | 1400 KB |