Submission #63397

# Submission time Handle Problem Language Result Execution time Memory
63397 2018-08-01T16:37:55 Z rzbt Zalmoxis (BOI18_zalmoxis) C++14
5 / 100
1000 ms 62724 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 1000006
using namespace std;
int n,k;

int l[MAXN],d[MAXN],niz[MAXN];
int orig[MAXN];
vector<int> gde[MAXN];
int main()
{
    scanf("%d %d", &n, &k);
    for(int i=1;i<=n;i++){

        scanf("%d",niz+i);
        orig[i]=niz[i];
        l[i]=i;
        d[i]=i;
    }
    for(int j=1;j<30;j++){
        for(int i=1;i<=n;i++){
            if(!niz[i] || niz[i]!=j)continue;
            if(niz[i]==niz[d[i]+1]){
                niz[d[i]+1]=0;
                niz[i]++;
                d[i]=d[d[i]+1];
            }else{
                gde[d[i]].pb(j);
                niz[i]++;
                k--;
            }
            i=d[i];
        }
    }

    for(int i=1;i<=n;i++){
        printf("%d ",orig[i]);
        if(k==0){
            for(auto x:gde[i])printf("%d ",x);
            continue;
        }

        reverse(all(gde[i]));
        while(!gde[i].empty()){
            if(k==0 || gde[i].back()==1){
                printf("%d ",gde[i].back());
                gde[i].pop_back();
            }else{
                k--;
                int nzm=gde[i].back()-1;
                gde[i].pop_back();
                gde[i].pb(nzm);gde[i].pb(nzm);
            }

        }

    }



    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:16: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:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",niz+i);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 59424 KB Time limit exceeded
2 Execution timed out 1078 ms 60016 KB Time limit exceeded
3 Execution timed out 1087 ms 60016 KB Time limit exceeded
4 Execution timed out 1080 ms 60016 KB Time limit exceeded
5 Execution timed out 1091 ms 61828 KB Time limit exceeded
6 Execution timed out 1085 ms 61828 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 62724 KB Time limit exceeded
2 Execution timed out 1069 ms 62724 KB Time limit exceeded
3 Execution timed out 1098 ms 62724 KB Time limit exceeded
4 Execution timed out 1080 ms 62724 KB Time limit exceeded
5 Execution timed out 1094 ms 62724 KB Time limit exceeded
6 Execution timed out 1078 ms 62724 KB Time limit exceeded
7 Execution timed out 1086 ms 62724 KB Time limit exceeded
8 Execution timed out 1079 ms 62724 KB Time limit exceeded
9 Execution timed out 1065 ms 62724 KB Time limit exceeded
10 Incorrect 322 ms 62724 KB not a zalsequence
11 Execution timed out 1076 ms 62724 KB Time limit exceeded
12 Incorrect 153 ms 62724 KB not a zalsequence
13 Incorrect 141 ms 62724 KB not a zalsequence
14 Correct 150 ms 62724 KB Output is correct