답안 #60720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60720 2018-07-24T15:12:28 Z alenam0161 Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
379 ms 10832 KB
#include <bits/stdc++.h>
using namespace std;
const int N  = 1000000+7;
int a[N];
int main(){
 
    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
    }
    stack<int> st;
    st.push(a[0]);
    vector<int> ans;
    ans.push_back(a[0]);
    for(int i=1;i<n;++i){
        if(a[i]>=st.top()){
            while(a[i]>=st.top()){
                int x=st.top();
                ans.push_back(x);
                st.pop();
                st.push(x+1);
                while(st.size()>=2){
                    int z=st.top();
                    st.pop();
                    if(z==st.top()){
                        st.pop();
                        st.push(z+1);
                    }
                    else{
                        st.push(z);
                        break;
                    }
                }
                k--;
            }

            k++;
        }
        else{
            ans.push_back(a[i]);
            st.push(a[i]);
        }
    }
    while(st.size()>1){
        int x=st.top();
        st.pop();
        int y=st.top();
        while(x<=y){
            ans.push_back(x);
            x++;
            k--;
        }
        st.pop();
        st.push(x);
        k++;
    }
    int z=st.top();
    while(k>0){
        ans.push_back(z);
        z++;
        k--;
    }
    for(int i=0;i<ans.size();++i){
        printf("%d ",a[i]);
    }
    printf("\n");
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:64:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ans.size();++i){
                 ~^~~~~~~~~~~
zalmoxis.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~
zalmoxis.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",a+i);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 238 ms 10332 KB Expected EOF
2 Incorrect 247 ms 10484 KB Expected EOF
3 Incorrect 282 ms 10484 KB Expected EOF
4 Incorrect 347 ms 10508 KB Expected EOF
5 Incorrect 379 ms 10508 KB Expected EOF
6 Incorrect 257 ms 10508 KB Expected EOF
# 결과 실행 시간 메모리 Grader output
1 Incorrect 256 ms 10616 KB Expected EOF
2 Incorrect 297 ms 10616 KB Expected EOF
3 Incorrect 242 ms 10616 KB Expected EOF
4 Incorrect 233 ms 10616 KB Expected EOF
5 Incorrect 259 ms 10616 KB Expected EOF
6 Incorrect 241 ms 10832 KB Expected EOF
7 Incorrect 223 ms 10832 KB Expected EOF
8 Incorrect 297 ms 10832 KB Expected EOF
9 Incorrect 233 ms 10832 KB Expected EOF
10 Incorrect 134 ms 10832 KB Expected EOF
11 Incorrect 186 ms 10832 KB Expected EOF
12 Incorrect 115 ms 10832 KB Expected EOF
13 Incorrect 118 ms 10832 KB Expected EOF
14 Incorrect 134 ms 10832 KB not a zalsequence