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>
using namespace std;
typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"
const int N = 1e6;
int a[1 + N];
vector <int> pos[1 + N];
int in_use[1 + N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
pos[a[i]].pb (i);
}
int ans = 0;
priority_queue <int> pq;
for (int i = 1; i <= N; i++) {
for (auto x : pos[i]) {
if (in_use[x] == 0) {
in_use[x] = 1;
ans++;
}
if (x + 1 <= n && !in_use[x + 1])
in_use[x + 1] = 1;
}
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |