문제출처 : https://www.acmicpc.net/problem/11509
code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int i, j, N, x, arrow, cnt = 0;
vector<int> balloon;
cin >> N;
for (i = 0; i < N; i++)
{
cin >> x;
balloon.push_back(x);
}
for (i = 0; i < N; i++)
{
if (balloon[i] != 0)
arrow = balloon[i];
else if (balloon[i] == 0)
continue;
for (j = i; j < N; j++)
{
if (balloon[j] == arrow)
{
balloon[j] = 0;
arrow--;
}
}
cnt++;
}
cout << cnt;
return 0;
}