Submission #4900

#TimeUsernameProblemLanguageResultExecution timeMemory
4900gs13068medians (balkan11_medians)C++98
100 / 100
36 ms1408 KiB
#include<cstdio> bool exist[300000]; int main() { int l,r,bef; int i,t,n; scanf("%d",&n); l=1;r=2*n-1; scanf("%d",&t); printf("%d",t); exist[t]=true; bef=t; for(i=1;i<n;i++) { scanf("%d",&t); if(!exist[t]) { exist[t]=true; printf(" %d",t); if(t<bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); } else { while(exist[r])r--; exist[r]=true; printf(" %d",r); } } else if(t==bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); while(exist[r])r--; exist[r]=true; printf(" %d",r); } else if(t<bef) { while(exist[l])l++; exist[l]=true; printf(" %d",l); while(exist[l])l++; exist[l]=true; printf(" %d",l); } else { while(exist[r])r--; exist[r]=true; printf(" %d",r); while(exist[r])r--; exist[r]=true; printf(" %d",r); } bef=t; } }

Compilation message (stderr)

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