답안 #50305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50305 2018-06-10T00:56:34 Z mra2322001 Money (IZhO17_money) C++14
45 / 100
1500 ms 152264 KB
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i<(n); i++)
#define f1(i, n) for(int i(1); i<=(n); i++)

using namespace std;
typedef long long ll;
const int N = 1e6 + 5;

int n, a[N], f[N];
set <int> s;

int solve(int u, int sl){
    if(u== n + 1) return printf("%d", sl), 0;
    int v = f[u];
    int l = u, r = v, ans = u;
    while(l <= r){
        int mid = (l + r)/2;
        auto it = s.lower_bound(a[mid]);
        --it;
        if(*it <= a[u]) l = mid + 1, ans = mid;
        else r = mid - 1;
    }
    for(int i = u; i <= ans; i++) s.insert(a[i]);
    solve(ans + 1, sl + 1);
}

int main(){
    ios_base::sync_with_stdio(0);

    scanf("%d", &n);
    f1(i, n) scanf("%d", &a[i]);
    for(int i = n; i >= 1; i--){
        if(i==n) f[i] = n;
        else{
            if(a[i] <= a[i + 1]) f[i] = f[i + 1];
            else f[i] = i;
        }
    }
    s.insert(0); s.insert(1e6 + 5);
    solve(1, 0);
}

Compilation message

money.cpp: In function 'int solve(int, int)':
money.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
money.cpp: In function 'int main()':
money.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
money.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     f1(i, n) scanf("%d", &a[i]);
              ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 800 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 4 ms 816 KB Output is correct
22 Correct 2 ms 820 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 2 ms 832 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 800 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 4 ms 816 KB Output is correct
22 Correct 2 ms 820 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 2 ms 832 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
27 Correct 3 ms 840 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 2 ms 976 KB Output is correct
30 Correct 2 ms 976 KB Output is correct
31 Correct 2 ms 976 KB Output is correct
32 Correct 2 ms 976 KB Output is correct
33 Correct 2 ms 976 KB Output is correct
34 Correct 2 ms 976 KB Output is correct
35 Correct 2 ms 976 KB Output is correct
36 Correct 2 ms 976 KB Output is correct
37 Correct 2 ms 976 KB Output is correct
38 Correct 2 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 700 KB Output is correct
10 Correct 2 ms 704 KB Output is correct
11 Correct 2 ms 704 KB Output is correct
12 Correct 3 ms 704 KB Output is correct
13 Correct 2 ms 704 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 2 ms 772 KB Output is correct
16 Correct 2 ms 776 KB Output is correct
17 Correct 2 ms 800 KB Output is correct
18 Correct 2 ms 808 KB Output is correct
19 Correct 2 ms 808 KB Output is correct
20 Correct 2 ms 812 KB Output is correct
21 Correct 4 ms 816 KB Output is correct
22 Correct 2 ms 820 KB Output is correct
23 Correct 2 ms 824 KB Output is correct
24 Correct 2 ms 828 KB Output is correct
25 Correct 2 ms 832 KB Output is correct
26 Correct 2 ms 836 KB Output is correct
27 Correct 3 ms 840 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 2 ms 976 KB Output is correct
30 Correct 2 ms 976 KB Output is correct
31 Correct 2 ms 976 KB Output is correct
32 Correct 2 ms 976 KB Output is correct
33 Correct 2 ms 976 KB Output is correct
34 Correct 2 ms 976 KB Output is correct
35 Correct 2 ms 976 KB Output is correct
36 Correct 2 ms 976 KB Output is correct
37 Correct 2 ms 976 KB Output is correct
38 Correct 2 ms 976 KB Output is correct
39 Correct 98 ms 7800 KB Output is correct
40 Correct 176 ms 15544 KB Output is correct
41 Correct 72 ms 15544 KB Output is correct
42 Correct 73 ms 17024 KB Output is correct
43 Correct 54 ms 17944 KB Output is correct
44 Correct 199 ms 30604 KB Output is correct
45 Correct 192 ms 37352 KB Output is correct
46 Correct 219 ms 44208 KB Output is correct
47 Correct 192 ms 50988 KB Output is correct
48 Correct 179 ms 57864 KB Output is correct
49 Correct 655 ms 83176 KB Output is correct
50 Correct 785 ms 90140 KB Output is correct
51 Correct 806 ms 96720 KB Output is correct
52 Correct 816 ms 103484 KB Output is correct
53 Correct 677 ms 110152 KB Output is correct
54 Correct 757 ms 117064 KB Output is correct
55 Execution timed out 1533 ms 152264 KB Time limit exceeded
56 Halted 0 ms 0 KB -