답안 #154146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154146 2019-09-18T15:16:43 Z mirceaishere Baloni (COCI15_baloni) C++14
0 / 100
395 ms 35320 KB
#include <iostream>
#include <vector>
using namespace std;

int n, i, j, x, f[1000005], sol, nrcrt, h;
vector<int>a[1000005];

int main(){
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>f[i];
    }
    for(i=n; i>0; i--){
        x=f[i];
        a[x].push_back(i);
    }
    nrcrt=1;
    while(nrcrt<=n){
        sol++;
        h=f[nrcrt];
        f[nrcrt]=0;
        a[h].pop_back();
        for(;;){
            h--;
            if(a[h].empty()){
                break;
            }
            x=a[h].back();
            f[x]=0;
            a[h].pop_back();
        }
        while(f[nrcrt]==0){
            nrcrt++;
        }
    }
    cout<<sol;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 23800 KB Output isn't correct
2 Incorrect 27 ms 23928 KB Output isn't correct
3 Incorrect 28 ms 23900 KB Output isn't correct
4 Incorrect 28 ms 23928 KB Output isn't correct
5 Incorrect 395 ms 35136 KB Output isn't correct
6 Incorrect 393 ms 35320 KB Output isn't correct
7 Incorrect 322 ms 34572 KB Output isn't correct
8 Incorrect 318 ms 32980 KB Output isn't correct
9 Incorrect 355 ms 35064 KB Output isn't correct
10 Incorrect 351 ms 34232 KB Output isn't correct