Submission #60730

# Submission time Handle Problem Language Result Execution time Memory
60730 2018-07-24T15:36:47 Z alenam0161 Zalmoxis (BOI18_zalmoxis) C++17
35 / 100
345 ms 11536 KB
#include <bits/stdc++.h>
void fl();
using namespace std;
const int N  = 1000000+7;
int a[N];
stack<int> st;
vector<int> ans;
void rem(){
    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;
        }
    }
}
int main(){

    int n,k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
    }
    st.push(a[0]);
    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.push(x);
                rem();
                k--;
            }
            ans.push_back(a[i]);
            st.push(a[i]);
            rem();
        }
        else{
            ans.push_back(a[i]);
            st.push(a[i]);
        }
    }
    while(st.size()>1){
        ans.push_back(st.top());
        st.push(st.top());
        rem();
        k--;
    }
    int z=st.top();
    while(k>0){
        ans.push_back(z);
        z++;
        k--;
    }
    for(int i=0;i<ans.size();++i){
        printf("%d ",ans[i]);
    }







    return 0;
}
void fl(){
    freopen("input.txt","r",stdin);
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:62:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<ans.size();++i){
                 ~^~~~~~~~~~~
zalmoxis.cpp:25: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:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",a+i);
         ~~~~~^~~~~~~~~~
zalmoxis.cpp: In function 'void fl()':
zalmoxis.cpp:75:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt","r",stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 242 ms 10296 KB Output is correct
2 Correct 315 ms 10436 KB Output is correct
3 Correct 234 ms 10444 KB Output is correct
4 Correct 345 ms 10756 KB Output is correct
5 Correct 255 ms 10756 KB Output is correct
6 Correct 316 ms 10756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 280 ms 10756 KB not a zalsequence
2 Correct 267 ms 10756 KB Output is correct
3 Incorrect 218 ms 10756 KB not a zalsequence
4 Incorrect 273 ms 10756 KB not a zalsequence
5 Incorrect 282 ms 10768 KB not a zalsequence
6 Incorrect 261 ms 10768 KB not a zalsequence
7 Incorrect 309 ms 10768 KB not a zalsequence
8 Incorrect 294 ms 10768 KB not a zalsequence
9 Incorrect 336 ms 10768 KB not a zalsequence
10 Incorrect 222 ms 10768 KB not a zalsequence
11 Incorrect 235 ms 10768 KB not a zalsequence
12 Incorrect 162 ms 11412 KB not a zalsequence
13 Incorrect 118 ms 11536 KB not a zalsequence
14 Incorrect 136 ms 11536 KB not a zalsequence