Submission #92506

# Submission time Handle Problem Language Result Execution time Memory
92506 2019-01-03T07:00:50 Z Randooom Money (IZhO17_money) C++14
100 / 100
670 ms 14968 KB
#include <bits/stdc++.h>
#define in freopen ("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long int

const int val = (1e6) + 5;
const int inf = (1e6);
double eps = 0.000000001;

using namespace std;

int a[val], d[val];

void update(int x){
    while(x <= inf){
        d[x] += 1;
        x += (x & -x);
    }
}

int get(int x){
    int s = 0;
    while(x > 0){
        s += d[x];
        x -= (x & -x);
    }
    return s;
}

int solve(){
    int n;
    cin >> n;
    for(int i=1; i<=n; ++i){
        cin >> a[i];
    }
    int x = inf, ans = 1;
    update(a[1]);
    update(inf);
    for(int i=2; i<=n; ++i){
        if(a[i] >= a[i-1] && a[i] <= x){
            update(a[i]);
        }
        else{
            int l = a[i], r = inf;
            while(l < r){
                int m = (l + r) / 2;
                if(get(m) > get(a[i])){
                    r = m;
                }
                else{
                    l = m + 1;
                }
            }
            x = l;
            update(a[i]);
            ++ ans;
        }
    }
    cout << ans << endl;
}

int main(){
    //in out
	ios_base::sync_with_stdio(0);
    solve();
    return 0;
}

Compilation message

money.cpp: In function 'int solve()':
money.cpp:60:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 420 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 420 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 508 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 4 ms 1540 KB Output is correct
38 Correct 3 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 1 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 420 KB Output is correct
21 Correct 2 ms 508 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 508 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 504 KB Output is correct
37 Correct 4 ms 1540 KB Output is correct
38 Correct 3 ms 1656 KB Output is correct
39 Correct 148 ms 2364 KB Output is correct
40 Correct 293 ms 3576 KB Output is correct
41 Correct 111 ms 2040 KB Output is correct
42 Correct 141 ms 2012 KB Output is correct
43 Correct 106 ms 1520 KB Output is correct
44 Correct 333 ms 4408 KB Output is correct
45 Correct 329 ms 4396 KB Output is correct
46 Correct 331 ms 4380 KB Output is correct
47 Correct 191 ms 4456 KB Output is correct
48 Correct 261 ms 4368 KB Output is correct
49 Correct 479 ms 8312 KB Output is correct
50 Correct 448 ms 8312 KB Output is correct
51 Correct 492 ms 8208 KB Output is correct
52 Correct 464 ms 8096 KB Output is correct
53 Correct 481 ms 8184 KB Output is correct
54 Correct 462 ms 8184 KB Output is correct
55 Correct 616 ms 8300 KB Output is correct
56 Correct 625 ms 8208 KB Output is correct
57 Correct 629 ms 8312 KB Output is correct
58 Correct 629 ms 8312 KB Output is correct
59 Correct 629 ms 14968 KB Output is correct
60 Correct 670 ms 14968 KB Output is correct
61 Correct 642 ms 14840 KB Output is correct
62 Correct 635 ms 14968 KB Output is correct