# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
708997 | vjudge1 | Baloni (COCI15_baloni) | C++17 | 838 ms | 95940 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>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define freopen(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
const int N = 1e6 + 5;
const int M = 3e3 + 5;
const ll mod = 1e9 + 7;
const ll inf = 1e7;
int n, h[N], id, x, ans;
set<int> st[N];
main() {
fast
cin >> n;
for(int i = 1; i <= n; i++){
cin >> h[i];
st[h[i]].insert(i);
}
for(int i = 1000000; i >= 1; i--){
while(st[i].size()){
x = i;
id = *st[i].begin();
while(x && st[x].size()){
if(st[x].lower_bound(id) == st[x].end()) break;
id = *st[x].lower_bound(id);
st[x].erase(id);
x--;
}
ans++;
}
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |