# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
649458 | ymm | Baloni (COCI15_baloni) | C++17 | 750 ms | 92432 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>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 1'000'010;
set<int> balloons[N];
int n;
void shoot(int h)
{
int lst = -1;
while (h >= 0) {
auto it = balloons[h].upper_bound(lst);
if (it == balloons[h].end())
break;
lst = *it;
balloons[h].erase(it);
--h;
}
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n;
Loop (i,0,n) {
int h;
cin >> h;
balloons[h].insert(i);
}
int ans = 0;
LoopR (i,0,N) {
while (balloons[i].size()) {
shoot(i);
++ans;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |