Submission #36946

# Submission time Handle Problem Language Result Execution time Memory
36946 2017-12-19T14:23:16 Z nickyrio Money (IZhO17_money) C++14
45 / 100
1500 ms 52788 KB
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<= b; ++i)
#define FORD(i, a, b) for (int i = a; i>=b; --i)
#define REP(i, a) for (int i = 0; i<a; ++i)
#define N 1001000
#define pp pair<int, int>
#define bit(S, i) (((S) >> i) & 1)
#define IO cin.tie(NULL);cout.tie(NULL);
#define taskname "test"
using namespace std;

int n, a[N];
set<int> used;
int main() {
    //freopen(taskname".inp","r",stdin);
    //freopen(taskname".out","w",stdout);
    IO;
    scanf("%d", &n);
    FOR(i, 1, n) scanf("%d", &a[i]);
    int start = 1;
    int cnt = 0;
    while (start <= n) {
        cnt++;
        int last = start + 1;
        used.insert(a[start]);
        int lim;
        if (used.upper_bound(a[start]) == used.end()) lim = 1e9;
        else lim = *used.upper_bound(a[start]);
        while (last <= n && a[last] <= lim && a[last] >= a[last - 1]) {
            used.insert(a[last]); last++; 
        }
        start = last;
    }
    printf("%d", cnt);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:18:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
money.cpp:19:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     FOR(i, 1, n) scanf("%d", &a[i]);
                                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 0 ms 5928 KB Output is correct
12 Correct 0 ms 5928 KB Output is correct
13 Correct 0 ms 5928 KB Output is correct
14 Correct 0 ms 5928 KB Output is correct
15 Correct 0 ms 5928 KB Output is correct
16 Correct 0 ms 5928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 0 ms 5928 KB Output is correct
12 Correct 0 ms 5928 KB Output is correct
13 Correct 0 ms 5928 KB Output is correct
14 Correct 0 ms 5928 KB Output is correct
15 Correct 0 ms 5928 KB Output is correct
16 Correct 0 ms 5928 KB Output is correct
17 Correct 0 ms 5928 KB Output is correct
18 Correct 0 ms 5928 KB Output is correct
19 Correct 0 ms 5928 KB Output is correct
20 Correct 0 ms 5928 KB Output is correct
21 Correct 0 ms 5928 KB Output is correct
22 Correct 0 ms 5928 KB Output is correct
23 Correct 0 ms 5928 KB Output is correct
24 Correct 0 ms 5928 KB Output is correct
25 Correct 0 ms 5928 KB Output is correct
26 Correct 0 ms 5928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 0 ms 5928 KB Output is correct
12 Correct 0 ms 5928 KB Output is correct
13 Correct 0 ms 5928 KB Output is correct
14 Correct 0 ms 5928 KB Output is correct
15 Correct 0 ms 5928 KB Output is correct
16 Correct 0 ms 5928 KB Output is correct
17 Correct 0 ms 5928 KB Output is correct
18 Correct 0 ms 5928 KB Output is correct
19 Correct 0 ms 5928 KB Output is correct
20 Correct 0 ms 5928 KB Output is correct
21 Correct 0 ms 5928 KB Output is correct
22 Correct 0 ms 5928 KB Output is correct
23 Correct 0 ms 5928 KB Output is correct
24 Correct 0 ms 5928 KB Output is correct
25 Correct 0 ms 5928 KB Output is correct
26 Correct 0 ms 5928 KB Output is correct
27 Correct 0 ms 5928 KB Output is correct
28 Correct 0 ms 5928 KB Output is correct
29 Correct 0 ms 5928 KB Output is correct
30 Correct 0 ms 5928 KB Output is correct
31 Correct 0 ms 5928 KB Output is correct
32 Correct 0 ms 5928 KB Output is correct
33 Correct 0 ms 5928 KB Output is correct
34 Correct 0 ms 5928 KB Output is correct
35 Correct 0 ms 5928 KB Output is correct
36 Correct 0 ms 5928 KB Output is correct
37 Correct 0 ms 5928 KB Output is correct
38 Correct 0 ms 5928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5928 KB Output is correct
2 Correct 0 ms 5928 KB Output is correct
3 Correct 0 ms 5928 KB Output is correct
4 Correct 0 ms 5928 KB Output is correct
5 Correct 0 ms 5928 KB Output is correct
6 Correct 0 ms 5928 KB Output is correct
7 Correct 0 ms 5928 KB Output is correct
8 Correct 0 ms 5928 KB Output is correct
9 Correct 0 ms 5928 KB Output is correct
10 Correct 0 ms 5928 KB Output is correct
11 Correct 0 ms 5928 KB Output is correct
12 Correct 0 ms 5928 KB Output is correct
13 Correct 0 ms 5928 KB Output is correct
14 Correct 0 ms 5928 KB Output is correct
15 Correct 0 ms 5928 KB Output is correct
16 Correct 0 ms 5928 KB Output is correct
17 Correct 0 ms 5928 KB Output is correct
18 Correct 0 ms 5928 KB Output is correct
19 Correct 0 ms 5928 KB Output is correct
20 Correct 0 ms 5928 KB Output is correct
21 Correct 0 ms 5928 KB Output is correct
22 Correct 0 ms 5928 KB Output is correct
23 Correct 0 ms 5928 KB Output is correct
24 Correct 0 ms 5928 KB Output is correct
25 Correct 0 ms 5928 KB Output is correct
26 Correct 0 ms 5928 KB Output is correct
27 Correct 0 ms 5928 KB Output is correct
28 Correct 0 ms 5928 KB Output is correct
29 Correct 0 ms 5928 KB Output is correct
30 Correct 0 ms 5928 KB Output is correct
31 Correct 0 ms 5928 KB Output is correct
32 Correct 0 ms 5928 KB Output is correct
33 Correct 0 ms 5928 KB Output is correct
34 Correct 0 ms 5928 KB Output is correct
35 Correct 0 ms 5928 KB Output is correct
36 Correct 0 ms 5928 KB Output is correct
37 Correct 0 ms 5928 KB Output is correct
38 Correct 0 ms 5928 KB Output is correct
39 Correct 109 ms 5928 KB Output is correct
40 Correct 183 ms 5928 KB Output is correct
41 Correct 79 ms 5928 KB Output is correct
42 Correct 56 ms 5928 KB Output is correct
43 Correct 59 ms 5928 KB Output is correct
44 Correct 209 ms 5928 KB Output is correct
45 Correct 226 ms 5928 KB Output is correct
46 Correct 246 ms 5928 KB Output is correct
47 Correct 186 ms 5928 KB Output is correct
48 Correct 169 ms 5928 KB Output is correct
49 Correct 939 ms 24408 KB Output is correct
50 Correct 963 ms 24408 KB Output is correct
51 Correct 956 ms 24408 KB Output is correct
52 Correct 899 ms 24408 KB Output is correct
53 Correct 933 ms 24408 KB Output is correct
54 Correct 1036 ms 24408 KB Output is correct
55 Execution timed out 1500 ms 52788 KB Execution timed out
56 Halted 0 ms 0 KB -