답안 #94415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94415 2019-01-18T09:37:30 Z Kastanda Money (IZhO17_money) C++11
100 / 100
264 ms 18808 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1000006;
int n, cnt, A[N], C[N], nxt[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &A[i]), C[A[i]] ++;
    C[N - 1] ++;
    for (int i = N - 2; i; i--)
    {
        nxt[i] = i + 1;
        while (!C[nxt[i]])
            nxt[i] = nxt[nxt[i]];
    }
    for (int i = n; i;)
    {
        int used = 0;
        int l = i - 1;
        while (l)
        {
            C[A[l + 1]] --;
            if (A[l] > A[l + 1])
                break;
            if (A[l] == A[l + 1])
            {
                l --;
                continue;
            }
            while (!C[nxt[A[l]]])
                nxt[A[l]] = nxt[nxt[A[l]]];
            if (nxt[A[l]] < A[l + 1])
                break;
            if (nxt[A[l]] == A[l + 1] && used)
                break;
            used = 1;
            l --;
        }
        i = l;
        cnt ++;
    }
    return !printf("%d", cnt);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
money.cpp:9:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &A[i]), C[A[i]] ++;
         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 7 ms 4216 KB Output is correct
6 Correct 7 ms 4216 KB Output is correct
7 Correct 7 ms 4216 KB Output is correct
8 Correct 7 ms 4216 KB Output is correct
9 Correct 7 ms 4216 KB Output is correct
10 Correct 7 ms 4216 KB Output is correct
11 Correct 7 ms 4344 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 7 ms 4216 KB Output is correct
14 Correct 7 ms 4216 KB Output is correct
15 Correct 12 ms 4344 KB Output is correct
16 Correct 8 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 7 ms 4216 KB Output is correct
6 Correct 7 ms 4216 KB Output is correct
7 Correct 7 ms 4216 KB Output is correct
8 Correct 7 ms 4216 KB Output is correct
9 Correct 7 ms 4216 KB Output is correct
10 Correct 7 ms 4216 KB Output is correct
11 Correct 7 ms 4344 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 7 ms 4216 KB Output is correct
14 Correct 7 ms 4216 KB Output is correct
15 Correct 12 ms 4344 KB Output is correct
16 Correct 8 ms 4344 KB Output is correct
17 Correct 7 ms 4344 KB Output is correct
18 Correct 8 ms 4216 KB Output is correct
19 Correct 7 ms 4344 KB Output is correct
20 Correct 7 ms 4188 KB Output is correct
21 Correct 7 ms 4344 KB Output is correct
22 Correct 7 ms 4344 KB Output is correct
23 Correct 7 ms 4216 KB Output is correct
24 Correct 7 ms 4216 KB Output is correct
25 Correct 7 ms 4344 KB Output is correct
26 Correct 7 ms 4344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 7 ms 4216 KB Output is correct
6 Correct 7 ms 4216 KB Output is correct
7 Correct 7 ms 4216 KB Output is correct
8 Correct 7 ms 4216 KB Output is correct
9 Correct 7 ms 4216 KB Output is correct
10 Correct 7 ms 4216 KB Output is correct
11 Correct 7 ms 4344 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 7 ms 4216 KB Output is correct
14 Correct 7 ms 4216 KB Output is correct
15 Correct 12 ms 4344 KB Output is correct
16 Correct 8 ms 4344 KB Output is correct
17 Correct 7 ms 4344 KB Output is correct
18 Correct 8 ms 4216 KB Output is correct
19 Correct 7 ms 4344 KB Output is correct
20 Correct 7 ms 4188 KB Output is correct
21 Correct 7 ms 4344 KB Output is correct
22 Correct 7 ms 4344 KB Output is correct
23 Correct 7 ms 4216 KB Output is correct
24 Correct 7 ms 4216 KB Output is correct
25 Correct 7 ms 4344 KB Output is correct
26 Correct 7 ms 4344 KB Output is correct
27 Correct 7 ms 4216 KB Output is correct
28 Correct 7 ms 4216 KB Output is correct
29 Correct 8 ms 4216 KB Output is correct
30 Correct 7 ms 4216 KB Output is correct
31 Correct 7 ms 4188 KB Output is correct
32 Correct 7 ms 4216 KB Output is correct
33 Correct 7 ms 4216 KB Output is correct
34 Correct 7 ms 4316 KB Output is correct
35 Correct 7 ms 4268 KB Output is correct
36 Correct 7 ms 4344 KB Output is correct
37 Correct 8 ms 4856 KB Output is correct
38 Correct 8 ms 4836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4216 KB Output is correct
2 Correct 8 ms 4216 KB Output is correct
3 Correct 7 ms 4216 KB Output is correct
4 Correct 7 ms 4216 KB Output is correct
5 Correct 7 ms 4216 KB Output is correct
6 Correct 7 ms 4216 KB Output is correct
7 Correct 7 ms 4216 KB Output is correct
8 Correct 7 ms 4216 KB Output is correct
9 Correct 7 ms 4216 KB Output is correct
10 Correct 7 ms 4216 KB Output is correct
11 Correct 7 ms 4344 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 7 ms 4216 KB Output is correct
14 Correct 7 ms 4216 KB Output is correct
15 Correct 12 ms 4344 KB Output is correct
16 Correct 8 ms 4344 KB Output is correct
17 Correct 7 ms 4344 KB Output is correct
18 Correct 8 ms 4216 KB Output is correct
19 Correct 7 ms 4344 KB Output is correct
20 Correct 7 ms 4188 KB Output is correct
21 Correct 7 ms 4344 KB Output is correct
22 Correct 7 ms 4344 KB Output is correct
23 Correct 7 ms 4216 KB Output is correct
24 Correct 7 ms 4216 KB Output is correct
25 Correct 7 ms 4344 KB Output is correct
26 Correct 7 ms 4344 KB Output is correct
27 Correct 7 ms 4216 KB Output is correct
28 Correct 7 ms 4216 KB Output is correct
29 Correct 8 ms 4216 KB Output is correct
30 Correct 7 ms 4216 KB Output is correct
31 Correct 7 ms 4188 KB Output is correct
32 Correct 7 ms 4216 KB Output is correct
33 Correct 7 ms 4216 KB Output is correct
34 Correct 7 ms 4316 KB Output is correct
35 Correct 7 ms 4268 KB Output is correct
36 Correct 7 ms 4344 KB Output is correct
37 Correct 8 ms 4856 KB Output is correct
38 Correct 8 ms 4836 KB Output is correct
39 Correct 66 ms 6364 KB Output is correct
40 Correct 109 ms 7680 KB Output is correct
41 Correct 55 ms 6008 KB Output is correct
42 Correct 50 ms 5880 KB Output is correct
43 Correct 38 ms 5496 KB Output is correct
44 Correct 134 ms 8472 KB Output is correct
45 Correct 135 ms 8440 KB Output is correct
46 Correct 135 ms 8452 KB Output is correct
47 Correct 123 ms 8468 KB Output is correct
48 Correct 132 ms 8376 KB Output is correct
49 Correct 206 ms 12408 KB Output is correct
50 Correct 192 ms 12304 KB Output is correct
51 Correct 194 ms 12384 KB Output is correct
52 Correct 190 ms 12284 KB Output is correct
53 Correct 190 ms 12276 KB Output is correct
54 Correct 202 ms 12280 KB Output is correct
55 Correct 263 ms 12328 KB Output is correct
56 Correct 247 ms 18808 KB Output is correct
57 Correct 246 ms 18796 KB Output is correct
58 Correct 244 ms 18720 KB Output is correct
59 Correct 263 ms 18808 KB Output is correct
60 Correct 264 ms 18756 KB Output is correct
61 Correct 236 ms 18808 KB Output is correct
62 Correct 236 ms 18680 KB Output is correct