제출 #92506

#제출 시각아이디문제언어결과실행 시간메모리
92506RandooomMoney (IZhO17_money)C++14
100 / 100
670 ms14968 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

money.cpp: In function 'int solve()':
money.cpp:60:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...