// [ нvмegy ]
// OLPCHUYENTIN2023 GOTOHUE
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int long long
#define all(c) c.begin(), c.end()
#ifdef hvmegy
#define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
cerr << "[" << vars << " : ";
string delim = "";
(..., (cerr << delim << values, delim = ", "));
cerr << "]" << '\n';
}
#else
#define dbg(...)
#endif
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
int GOTOHUE();
void init();
int32_t main()
{
cin.tie(0) -> sync_with_stdio(0);
cout << fixed << setprecision(15);
#ifdef hvmegy
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("log.txt", "w", stderr);
#endif
// =============================
bool MULTITEST = 0;
// =============================
init();
int OLPCHUYENTIN2023 = 1;
if (MULTITEST) cin >> OLPCHUYENTIN2023;
for (int i = 1; i <= OLPCHUYENTIN2023; i++) {
if (GOTOHUE()) break;
#ifdef hvmegy
cout << "--ENDTEST--" << '\n';
cerr << "--ENDTEST--" << '\n';
#endif
}
#ifdef hvmegy
cerr << '\n' << clock() * 1000.0 / CLOCKS_PER_SEC << "ms" << '\n';
#endif
return 0;
}
void init() {
}
int GOTOHUE() {
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int ans = 0;
vector<int> ck(1e6 + 2);
for (int i = 1; i <= n; i++) {
if (ck[a[i] + 1]) {
ck[a[i] + 1]--;
ck[a[i]]++;
}
else {
ans++;
ck[a[i]]++;
}
}
cout << ans << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8284 KB |
Output is correct |
2 |
Correct |
2 ms |
8284 KB |
Output is correct |
3 |
Correct |
3 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8284 KB |
Output is correct |
5 |
Correct |
44 ms |
18004 KB |
Output is correct |
6 |
Correct |
52 ms |
18772 KB |
Output is correct |
7 |
Correct |
37 ms |
16732 KB |
Output is correct |
8 |
Correct |
38 ms |
16728 KB |
Output is correct |
9 |
Correct |
42 ms |
17308 KB |
Output is correct |
10 |
Correct |
52 ms |
17492 KB |
Output is correct |