# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
649458 | ymm | Baloni (COCI15_baloni) | C++17 | 750 ms | 92432 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |