# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599891 | starchan | Baloni (COCI15_baloni) | C++17 | 1072 ms | 59448 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 int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
set<in> cool;
signed main()
{
fast();
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
int x;
cin >> x;
cool.insert({-x, i});
}
int ans = 0;
while(cool.size())
{
ans++;
in fine = *cool.begin();
int curr = fine.f;
int index = fine.s;
cool.erase(cool.begin());
while(true)
{
if(cool.empty())
break;
auto it = cool.lower_bound({curr+1, index});
if(it == cool.end())
break;
if((*it).f == curr+1)
{
curr = (*it).f;
index = (*it).s;
cool.erase(it);
}
else
break;
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |