# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
480063 |
2021-10-14T13:57:05 Z |
NachoLibre |
Po (COCI21_po) |
C++17 |
|
54 ms |
6084 KB |
#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 |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
3180 KB |
Output isn't correct |
5 |
Incorrect |
39 ms |
4676 KB |
Output isn't correct |
6 |
Correct |
54 ms |
6064 KB |
Output is correct |
7 |
Incorrect |
39 ms |
6084 KB |
Output isn't correct |