#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
#define whole(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define ins insert
#define maxn int (1e6 + 1)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
//----------------------------------------------------------
int n, k, m;
int shot[maxn] = {}, h[maxn] = {};
void Input ()
{
cin >> n;
cerr << n;
for (int i = 1; i <= n; ++i)
cin >> h[i];
}
void Solve ()
{
for (int i = n; i >= 1; --i)
{
++shot[h[i]];
if (shot[h[i] - 1]) --shot[h[i] - 1];
}
int res = 0;
for (int i = 1; i < maxn; ++i) res += shot[i];
cout << res;
}
int main()
{
//freopen ("baloni.inp", "r", stdin);
//freopen ("baloni.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie (NULL);
cout.tie (NULL);
Input ();
Solve ();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
9988 KB |
Output is correct |
2 |
Correct |
0 ms |
9988 KB |
Output is correct |
3 |
Correct |
0 ms |
9988 KB |
Output is correct |
4 |
Correct |
0 ms |
9988 KB |
Output is correct |
5 |
Correct |
76 ms |
9988 KB |
Output is correct |
6 |
Correct |
113 ms |
9988 KB |
Output is correct |
7 |
Correct |
76 ms |
9988 KB |
Output is correct |
8 |
Correct |
69 ms |
9988 KB |
Output is correct |
9 |
Correct |
96 ms |
9988 KB |
Output is correct |
10 |
Correct |
76 ms |
9988 KB |
Output is correct |