# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
103616 |
2019-04-01T09:34:31 Z |
leonarda |
Baloni (COCI15_baloni) |
C++14 |
|
1550 ms |
92480 KB |
#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 |
1 |
Correct |
48 ms |
47352 KB |
Output is correct |
2 |
Correct |
51 ms |
47352 KB |
Output is correct |
3 |
Correct |
48 ms |
47488 KB |
Output is correct |
4 |
Correct |
53 ms |
47608 KB |
Output is correct |
5 |
Correct |
1535 ms |
87648 KB |
Output is correct |
6 |
Correct |
1550 ms |
92480 KB |
Output is correct |
7 |
Correct |
1297 ms |
84804 KB |
Output is correct |
8 |
Correct |
1278 ms |
84176 KB |
Output is correct |
9 |
Correct |
1439 ms |
86352 KB |
Output is correct |
10 |
Correct |
1416 ms |
87800 KB |
Output is correct |