# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
260157 | sckmd | Baloni (COCI15_baloni) | C++14 | 1410 ms | 45720 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 MAXN 1000005
typedef pair<int,int> pii;
set <pii> st;
void go(int height,int prev)
{
if(st.lower_bound({height,prev})==st.end())return ;
auto it = st.lower_bound({height,prev});
pii x = *it;
if(x.first != height)return ;
if(x.second < prev)return ;
st.erase(it);
go(height-1,x.second);
}
int solve()
{
int ans = 0;
for(int height = MAXN-1; height > 0;)
{
if(st.lower_bound({height,-1})==st.end()){height--;continue;}
/*auto it = st.lower_bound({height,-1});
pii x = *it;
if(x.first != height){height--;continue;}*/
go(height,-1);
ans++;
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int h;
cin >> h;
st.insert({h,i});
}
cout << solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |