# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103616 | leonarda | Baloni (COCI15_baloni) | C++14 | 1550 ms | 92480 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>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
int n, ans;
set<int> v[maxn];
int a[maxn];
bool memo[maxn];
int main ()
{
ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> a[i];
v[a[i]].insert(i);
}
for(int i = 0; i < n; ++i) {
if(v[a[i]].count(i) == 0)
continue;
int indeks = i;
while(indeks != -1) {
v[a[indeks]].erase(indeks);
set<int>::iterator it = v[a[indeks] - 1].lower_bound(indeks);
if(it == v[a[indeks] - 1].end())
indeks = -1;
else
indeks = *it;
}
++ans;
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |