# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251676 |
2020-07-22T07:11:28 Z |
VEGAnn |
Baloni (COCI15_baloni) |
C++14 |
|
2000 ms |
131072 KB |
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define i2 array<int,2>
using namespace std;
typedef long long ll;
const int N = 1000100;
const int C = 22;
const int md = 10007;
set<i2> st;
set<int> ps[N];
set<int>::iterator iter;
int n, a[N], ans;
int mult(int x, int y) { return (x * y) % md; }
void SUM(int &x, int y){
x += y;
if (x >= md)
x -= md;
}
int main() {
#ifdef _LOCAL
freopen("in.txt","r",stdin); // freopen("output.txt","w",stdout);
#else
// freopen("mining.in","r",stdin); freopen("mining.out","w",stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = n; i > 0; i--){
st.insert({a[i], -i});
ps[a[i]].insert(i);
}
while (sz(st) > 0){
ans++;
i2 cr = (*(--st.end()));
st.erase(cr);
int pst = -cr[1], vl = cr[0];
while (pst != 0){
if (sz(ps[vl - 1]) == 0) break;
iter = ps[vl - 1].upper_bound(pst);
if (iter == ps[vl - 1].end()) break;
ps[vl - 1].erase(iter);
pst = *iter;
vl--;
st.erase({a[pst], -pst});
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
47488 KB |
Output is correct |
2 |
Correct |
32 ms |
47488 KB |
Output is correct |
3 |
Correct |
26 ms |
47740 KB |
Output is correct |
4 |
Correct |
27 ms |
47744 KB |
Output is correct |
5 |
Execution timed out |
2094 ms |
124792 KB |
Time limit exceeded |
6 |
Runtime error |
1147 ms |
131072 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Correct |
1725 ms |
119032 KB |
Output is correct |
8 |
Correct |
1704 ms |
118008 KB |
Output is correct |
9 |
Execution timed out |
2043 ms |
121976 KB |
Time limit exceeded |
10 |
Execution timed out |
2007 ms |
124984 KB |
Time limit exceeded |