답안 #491764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
491764 2021-12-04T09:39:54 Z White Money (IZhO17_money) C++14
0 / 100
1 ms 332 KB
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;

int a[1000001],b[1000001],v[1000001];
bool bqh[1000001];

int main(){

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

    int n,br=0,now;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        v[i]=a[i];
    }
    sort(v,v+n+1);
    //cout<<v[1]<<v[2]<<v[3]<<endl;
    bool yes;
    for(int i=1;i<n;i++){
        if(a[i]!=v[i]){
            yes=false;
            now=i;
            for(int j=i+1;j<=n;j++){
                if(a[j]==v[i])yes=true;
                if(yes==true){
                    if(a[j]==v[i]){
                        b[now]=v[i];
                        bqh[j]=true;
                        now++;
                    }else{
                        while(j<=n && a[j]>a[j-1]){
                            b[now]=a[j];
                            bqh[j]=true;
                            now++;
                            j++;
                        }
                        if(j==n+1 && i<n-1 && a[i]==v[i+1])br--;
                        yes=false;
                    }
                }
            }
        //cout<<"OOOOOO"<<now<<endl;
            for(int j=i;j<=n;j++){
                if(bqh[j]==false){
                    b[now]=a[j];
                    now++;
                }
            }
            br++;
            //cout<<i<<"dwa"<<br<<endl;
            //cout<<b[1]<<b[2]<<endl;
            for(int j=i;j<=n;j++){
                a[j]=b[j];
                bqh[j]=false;
            }
        }
    }
    br++;
    cout<<br<<endl;

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