Submission #756880

#TimeUsernameProblemLanguageResultExecution timeMemory
756880KN200711medians (balkan11_medians)C++14
5 / 100
47 ms4156 KiB
# include <bits/stdc++.h> using namespace std; int ct[200001]; int mn, mx, N; void upd() { while(ct[mn] && mn <= N) mn++; while(ct[mx] && mx > 0) mx--; } int main() { scanf("%d", &N); vector<int> arr(N); for(int i=0;i<N;i++) scanf("%d", &arr[i]); vector<int> as; as.clear(); mn = 1; mx = 2 * N - 1; for(int i=0;i<N;i++) { if(i == 0) { as.push_back(arr[i]); ct[arr[i]]++; } else { upd(); if(arr[i] > arr[i - 1]) { as.push_back(arr[i]); as.push_back(mx); } else if(arr[i] < arr[i - 1]) { as.push_back(arr[i]); as.push_back(mn); } else { as.push_back(mn); as.push_back(mx); } ct[as.back()] = 1; ct[as[as.size() - 2]] = 1; } } for(int p=0;p<as.size();p++) printf("%d ", as[p]); printf("\n"); return 0; }

Compilation message (stderr)

medians.cpp: In function 'int main()':
medians.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int p=0;p<as.size();p++) printf("%d ", as[p]);
      |              ~^~~~~~~~~~
medians.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
medians.cpp:15:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...