#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
//#include <bit>
//#include <ranges>
//#include <numbers>
#define itn int
#define sacnf scanf
#define sz(a) ((int)((a).size()))
// printf("%.10f\n", ans);
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 5;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
for (int cnt = 1; ; cnt++)
{
int i;
for (i = 0; i < n; i++) if (v[i] != 2e9) break;
if (i == n) return cout << cnt - 1, 0;
int h = v[i];
for (; i < n; i++) if (v[i] == h) v[i] = 2e9, h--;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
3 ms |
212 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
9 ms |
340 KB |
Output is correct |
5 |
Correct |
752 ms |
7104 KB |
Output is correct |
6 |
Correct |
1864 ms |
7240 KB |
Output is correct |
7 |
Correct |
1671 ms |
5964 KB |
Output is correct |
8 |
Correct |
1527 ms |
5948 KB |
Output is correct |
9 |
Correct |
1128 ms |
6516 KB |
Output is correct |
10 |
Correct |
1568 ms |
6468 KB |
Output is correct |