답안 #519780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
519780 2022-01-27T10:29:37 Z Dasha_Gnedko Money (IZhO17_money) C++17
100 / 100
165 ms 25308 KB
#include <bits/stdc++.h>

//#include <ext/pb_ds/detail/standard_policies.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

using namespace std;

//using namespace __gnu_pbds;
//template <typename T> using ordered_set = tree <T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 gen(time(0));

#define ll long long
#define ld long double
#define pb push_back
#define F first
#define S second
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define sz(a) int32_t(a.size())
#define endl '\n'
//#define int long long

const int N = 1e6 + 100;
const int M = 31;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;

int a[N], nxt[N], cnt[N], cl[N];

int get(int v)
{
    if (v >= N - 1) return N - 1;
    if (cnt[v]) return v;
    return nxt[v] = get(nxt[v]);
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // LOCAL

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i = 0; i < N - 1; i++)
        nxt[i] = i + 1;
    for(int i = n - 1; i >= 0; i--)
    {
        cnt[a[i]]--;
        cl[i] = get(a[i] + 1);
    }
    int ans = 0;
    for(int i = 0; i < n; )
    {
        ans++;
        int j = i + 1;
        int x = cl[i];
        while (j < n && a[j - 1] <= a[j] && a[j] <= x)
            j++;
        i = j;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19916 KB Output is correct
2 Correct 16 ms 19788 KB Output is correct
3 Correct 13 ms 19820 KB Output is correct
4 Correct 14 ms 19788 KB Output is correct
5 Correct 14 ms 19892 KB Output is correct
6 Correct 15 ms 19788 KB Output is correct
7 Correct 10 ms 9024 KB Output is correct
8 Correct 5 ms 8536 KB Output is correct
9 Correct 10 ms 10828 KB Output is correct
10 Correct 8 ms 10828 KB Output is correct
11 Correct 12 ms 13376 KB Output is correct
12 Correct 7 ms 8684 KB Output is correct
13 Correct 10 ms 13260 KB Output is correct
14 Correct 10 ms 11908 KB Output is correct
15 Correct 8 ms 9932 KB Output is correct
16 Correct 10 ms 9800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19916 KB Output is correct
2 Correct 16 ms 19788 KB Output is correct
3 Correct 13 ms 19820 KB Output is correct
4 Correct 14 ms 19788 KB Output is correct
5 Correct 14 ms 19892 KB Output is correct
6 Correct 15 ms 19788 KB Output is correct
7 Correct 10 ms 9024 KB Output is correct
8 Correct 5 ms 8536 KB Output is correct
9 Correct 10 ms 10828 KB Output is correct
10 Correct 8 ms 10828 KB Output is correct
11 Correct 12 ms 13376 KB Output is correct
12 Correct 7 ms 8684 KB Output is correct
13 Correct 10 ms 13260 KB Output is correct
14 Correct 10 ms 11908 KB Output is correct
15 Correct 8 ms 9932 KB Output is correct
16 Correct 10 ms 9800 KB Output is correct
17 Correct 8 ms 10360 KB Output is correct
18 Correct 10 ms 11084 KB Output is correct
19 Correct 10 ms 8184 KB Output is correct
20 Correct 10 ms 11652 KB Output is correct
21 Correct 8 ms 9292 KB Output is correct
22 Correct 7 ms 10700 KB Output is correct
23 Correct 5 ms 7116 KB Output is correct
24 Correct 9 ms 10036 KB Output is correct
25 Correct 6 ms 7244 KB Output is correct
26 Correct 7 ms 8692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19916 KB Output is correct
2 Correct 16 ms 19788 KB Output is correct
3 Correct 13 ms 19820 KB Output is correct
4 Correct 14 ms 19788 KB Output is correct
5 Correct 14 ms 19892 KB Output is correct
6 Correct 15 ms 19788 KB Output is correct
7 Correct 10 ms 9024 KB Output is correct
8 Correct 5 ms 8536 KB Output is correct
9 Correct 10 ms 10828 KB Output is correct
10 Correct 8 ms 10828 KB Output is correct
11 Correct 12 ms 13376 KB Output is correct
12 Correct 7 ms 8684 KB Output is correct
13 Correct 10 ms 13260 KB Output is correct
14 Correct 10 ms 11908 KB Output is correct
15 Correct 8 ms 9932 KB Output is correct
16 Correct 10 ms 9800 KB Output is correct
17 Correct 8 ms 10360 KB Output is correct
18 Correct 10 ms 11084 KB Output is correct
19 Correct 10 ms 8184 KB Output is correct
20 Correct 10 ms 11652 KB Output is correct
21 Correct 8 ms 9292 KB Output is correct
22 Correct 7 ms 10700 KB Output is correct
23 Correct 5 ms 7116 KB Output is correct
24 Correct 9 ms 10036 KB Output is correct
25 Correct 6 ms 7244 KB Output is correct
26 Correct 7 ms 8692 KB Output is correct
27 Correct 16 ms 19904 KB Output is correct
28 Correct 13 ms 19916 KB Output is correct
29 Correct 16 ms 19788 KB Output is correct
30 Correct 15 ms 19904 KB Output is correct
31 Correct 13 ms 19788 KB Output is correct
32 Correct 8 ms 9548 KB Output is correct
33 Correct 8 ms 9400 KB Output is correct
34 Correct 8 ms 8908 KB Output is correct
35 Correct 9 ms 12364 KB Output is correct
36 Correct 12 ms 12620 KB Output is correct
37 Correct 7 ms 5412 KB Output is correct
38 Correct 8 ms 5580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 19916 KB Output is correct
2 Correct 16 ms 19788 KB Output is correct
3 Correct 13 ms 19820 KB Output is correct
4 Correct 14 ms 19788 KB Output is correct
5 Correct 14 ms 19892 KB Output is correct
6 Correct 15 ms 19788 KB Output is correct
7 Correct 10 ms 9024 KB Output is correct
8 Correct 5 ms 8536 KB Output is correct
9 Correct 10 ms 10828 KB Output is correct
10 Correct 8 ms 10828 KB Output is correct
11 Correct 12 ms 13376 KB Output is correct
12 Correct 7 ms 8684 KB Output is correct
13 Correct 10 ms 13260 KB Output is correct
14 Correct 10 ms 11908 KB Output is correct
15 Correct 8 ms 9932 KB Output is correct
16 Correct 10 ms 9800 KB Output is correct
17 Correct 8 ms 10360 KB Output is correct
18 Correct 10 ms 11084 KB Output is correct
19 Correct 10 ms 8184 KB Output is correct
20 Correct 10 ms 11652 KB Output is correct
21 Correct 8 ms 9292 KB Output is correct
22 Correct 7 ms 10700 KB Output is correct
23 Correct 5 ms 7116 KB Output is correct
24 Correct 9 ms 10036 KB Output is correct
25 Correct 6 ms 7244 KB Output is correct
26 Correct 7 ms 8692 KB Output is correct
27 Correct 16 ms 19904 KB Output is correct
28 Correct 13 ms 19916 KB Output is correct
29 Correct 16 ms 19788 KB Output is correct
30 Correct 15 ms 19904 KB Output is correct
31 Correct 13 ms 19788 KB Output is correct
32 Correct 8 ms 9548 KB Output is correct
33 Correct 8 ms 9400 KB Output is correct
34 Correct 8 ms 8908 KB Output is correct
35 Correct 9 ms 12364 KB Output is correct
36 Correct 12 ms 12620 KB Output is correct
37 Correct 7 ms 5412 KB Output is correct
38 Correct 8 ms 5580 KB Output is correct
39 Correct 68 ms 16756 KB Output is correct
40 Correct 100 ms 16412 KB Output is correct
41 Correct 51 ms 17448 KB Output is correct
42 Correct 37 ms 10224 KB Output is correct
43 Correct 33 ms 9304 KB Output is correct
44 Correct 96 ms 16280 KB Output is correct
45 Correct 101 ms 18308 KB Output is correct
46 Correct 94 ms 17220 KB Output is correct
47 Correct 115 ms 25308 KB Output is correct
48 Correct 98 ms 19652 KB Output is correct
49 Correct 131 ms 16428 KB Output is correct
50 Correct 122 ms 16340 KB Output is correct
51 Correct 133 ms 16336 KB Output is correct
52 Correct 117 ms 16260 KB Output is correct
53 Correct 120 ms 16252 KB Output is correct
54 Correct 127 ms 16324 KB Output is correct
55 Correct 130 ms 16284 KB Output is correct
56 Correct 130 ms 16324 KB Output is correct
57 Correct 153 ms 16232 KB Output is correct
58 Correct 151 ms 16252 KB Output is correct
59 Correct 123 ms 16296 KB Output is correct
60 Correct 128 ms 16408 KB Output is correct
61 Correct 165 ms 16284 KB Output is correct
62 Correct 121 ms 16280 KB Output is correct