# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
103614 |
2019-04-01T08:12:06 Z |
leonarda |
Baloni (COCI15_baloni) |
C++14 |
|
2000 ms |
93424 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) {
// cout << "i " << i << endl;
if(!memo[i]) {
memo[i] = 1;
int indeks = i + 1;
int h = a[i];
--h;
for(int j = a[i] - 1; j >= 0; --j) {
bool ok = 0;
for(set<int>::iterator it = v[j].begin(); it != v[j].end(); ++it) {
if(*it >= indeks and a[*it] == h) {
memo[*it] = 1;
indeks = *it + 1;
--h;
ok = 1;
continue;
// break;
}
}
if(!ok) break;
}
++ans;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
47360 KB |
Output isn't correct |
2 |
Incorrect |
44 ms |
47324 KB |
Output isn't correct |
3 |
Incorrect |
45 ms |
47452 KB |
Output isn't correct |
4 |
Incorrect |
46 ms |
47608 KB |
Output isn't correct |
5 |
Execution timed out |
2055 ms |
88592 KB |
Time limit exceeded |
6 |
Execution timed out |
2051 ms |
93424 KB |
Time limit exceeded |
7 |
Execution timed out |
2053 ms |
85444 KB |
Time limit exceeded |
8 |
Execution timed out |
2061 ms |
84808 KB |
Time limit exceeded |
9 |
Execution timed out |
2071 ms |
87032 KB |
Time limit exceeded |
10 |
Execution timed out |
2047 ms |
88460 KB |
Time limit exceeded |