Created
April 30, 2017 14:15
-
-
Save Acarus/92750422ee1c1cd18c2696ffa2bdcb52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
using ll = long long; | |
using ld = long double; | |
int main(int argc, char **argv) { | |
ios::sync_with_stdio(false); | |
srand(time(0)); | |
#ifdef HOME | |
freopen("/home/acarus/Desktop/io/input.txt", "r", stdin); | |
// freopen("/home/acarus/Desktop/io/output.txt", "w", stdout); | |
#endif | |
int n; | |
cin >> n; | |
vector<pair<int, int>> v; | |
for (int i = 1; i <= n; ++i) { | |
int x; | |
cin >> x; | |
v.push_back(make_pair(x, i)); | |
} | |
int ans = 1; | |
sort(begin(v), end(v)); | |
for (int i = 1; i < n; ++i) { | |
if (v[i].second < v[i - 1].second) ++ans; | |
} | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment