Submission #14815

#TimeUsernameProblemLanguageResultExecution timeMemory
14815eaststarmedians (balkan11_medians)C++98
100 / 100
33 ms1896 KiB
#include <stdio.h> int a[200010],f,r; int main(){ int i,n,m,k; scanf("%d",&n); scanf("%d",&m); printf("%d",m); a[m]=1; r=n*2; for(i=1;i<n;++i){ scanf("%d",&k); if(k<m){ if(a[k]){ while(a[++f]); printf(" %d",f); } else printf(" %d",k); a[k]=1; while(a[++f]); printf(" %d",f); a[f]=1; } else if(k==m){ while(a[++f]); while(a[--r]); printf(" %d %d",f,r); a[k]=a[f]=a[r]=1; } else{ if(a[k]){ while(a[--r]); printf(" %d",r); } else printf(" %d",k); a[k]=1; while(a[--r]); printf(" %d",r); a[r]=1; } m=k; } return 0; }

Compilation message (stderr)

medians.cpp: In function 'int main()':
medians.cpp:5:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
medians.cpp:6:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&m);
                   ^
medians.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...