// Ahmadov orz
/// successful failure
#include <bits/stdc++.h>
/// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
/// using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define drop(x) cout<<x<<endl;return
// template <class T>
// using isTree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/// sometimes you gotta think simple
struct custom_hash {
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
x ^= FIXED_RANDOM;
return x ^ (x >> 16);
}
};
const int N = 1e6 + 7;
int vis[N];
void failure()
{
int n;
cin >> n;
vector <int> arr(n);
//map <int,int> mp;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (vis[arr[i]]) {
vis[arr[i]]--;
}
else {
ans++;
}
vis[arr[i] - 1]++;
}
drop(ans);
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int tt = 1;
//cin >> tt;
while (tt--)
{
failure();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
36 ms |
6652 KB |
Output is correct |
6 |
Correct |
37 ms |
7248 KB |
Output is correct |
7 |
Correct |
33 ms |
7752 KB |
Output is correct |
8 |
Correct |
29 ms |
5968 KB |
Output is correct |
9 |
Correct |
34 ms |
6224 KB |
Output is correct |
10 |
Correct |
32 ms |
6664 KB |
Output is correct |