# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
480063 | NachoLibre | Po (COCI21_po) | C++17 | 54 ms | 6084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define sz(x) ((int)x.size())
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n + 1);
vector<pair<int, int>> b(n + 1);
for(int i = 1; i <= n; ++i) {
cin >> a[i];
b[i].first = a[i];
b[i].second = i;
}
sort(b.begin() + 1, b.end());
set<int> s;
s.insert(n + 1);
int ans = 0;
for(int i = 1; i <= n; ) {
int j = i;
for(int k = i; k <= n; ++k) {
if(b[k].first != b[i].first) break;
j = k;
}
++ans;
for(int k = i + 1; k <= j; ++k) {
int x = *(s.upper_bound(b[k - 1].second));
int y = *(s.upper_bound(b[k].second));
if(x != y) ++ans;
}
for(int k = i; k <= j; ++k) {
s.insert(b[k].second);
}
i = j + 1;
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |