Submission #14215

#TimeUsernameProblemLanguageResultExecution timeMemory
14215Fakeablemedians (balkan11_medians)C++98
100 / 100
33 ms1312 KiB
#include<cstdio> bool chk[200200]; int main() { int n,front; scanf("%d",&n); int left=1, right=2*n-1; scanf("%d",&front); printf("%d ",front); chk[front]=true; int mid=front; for(int i=1;i<n;i++) { scanf("%d",&front); if(!chk[front]) { printf("%d ",front); chk[front]=true; if(front<mid) { while(chk[left]) left++; chk[left]=true; printf("%d ",left); } else { while(chk[right]) right--; chk[right]=true; printf("%d ",right); } } else if(front==mid) { while(chk[left]) left++; while(chk[right]) right--; chk[left]=chk[right]=true; printf("%d %d ",left,right); } else if(front<mid) { while(chk[left]) left++; chk[left]=true; printf("%d ",left); while(chk[left]) left++; chk[left]=true; printf("%d ",left); } else { while(chk[right]) right--; chk[right]=true; printf("%d ",right); while(chk[right]) right--; chk[right]=true; printf("%d ",right); } mid=front; } return 0; }

Compilation message (stderr)

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