#include <bits/stdc++.h>
using namespace std;
multiset<int> s;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, cnt=0;
cin >> n;
for (int i=1; i<=n; i++)
{
int x;
cin >> x;
auto itr=s.lower_bound(x);
if (itr!=s.end() && (*itr)==x)
s.erase(itr);
else
cnt++;
s.insert(x-1);
}
cout << cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
175 ms |
3932 KB |
Output is correct |
6 |
Correct |
210 ms |
3888 KB |
Output is correct |
7 |
Correct |
183 ms |
3276 KB |
Output is correct |
8 |
Correct |
174 ms |
3160 KB |
Output is correct |
9 |
Correct |
174 ms |
3592 KB |
Output is correct |
10 |
Correct |
183 ms |
3496 KB |
Output is correct |