#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
const int INF = 2e5 + 100;
int n;
vi h;
mii mp;
int32_t main(){
cin >> n;
h.resize(n);
for (int i = 0; i < n; i++){
cin >> h[i];
}
int cnt = 0;
for (int i = 0; i < n; i++){
if (mp[h[i]+1] == 0) cnt++;
else mp[h[i]+1]--;
mp[h[i]]++;
}
cout << cnt;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
234 ms |
6624 KB |
Output is correct |
6 |
Correct |
212 ms |
7368 KB |
Output is correct |
7 |
Correct |
163 ms |
6152 KB |
Output is correct |
8 |
Correct |
165 ms |
6160 KB |
Output is correct |
9 |
Correct |
199 ms |
6396 KB |
Output is correct |
10 |
Correct |
179 ms |
6480 KB |
Output is correct |