답안 #491886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491886 2021-12-04T22:27:01 Z White Money (IZhO17_money) C++14
0 / 100
0 ms 204 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int num[1000001];
vector<int>ans,b,c;

int binn(int now){
    int l=0,r=ans.size()-1,mid;
    mid=(l+r)/2;
    //cout<<r<<endl;
    while(l<r){
        if(ans[mid]<=num[now])l=mid+1;
        else r=mid;
        mid=(l+r)/2;
    }
    //cout<<"adwwda"<<now<<endl;
    return l;
}

int main (){

    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    int n,br=0;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>num[i];
    ans.push_back(0);ans.push_back(1000002);

    for(int i=1;i<=n;){
        int j=0;
        //cout<<"daw"<<endl;
        j=binn(i);
        ans.insert(ans.begin()+j,num[i]);
        br++;
        i++;
        while(i<=n && num[i-1]<=num[i] && num[i]<=ans[j+1]){
            j++;
            b.push_back(num[j]);
            i++;
        }
        ans.insert(ans.end(), b.begin(), b.end());
        b=c;
    }
    cout<<br<<endl;

return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -