Submission #30895

#TimeUsernameProblemLanguageResultExecution timeMemory
30895Navickmedians (balkan11_medians)C++14
100 / 100
129 ms12956 KiB
#include <bits/stdc++.h> #define F first #define S second #define pii pair<int, int> #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const int N = 2e5 + 10; set<int> st; int a[N], b[N]; int main(){ int n; scanf("%d", &n); for(int i=1; i<2*n; i++) st.insert(i); for(int i=0; i<n; i++){ scanf("%d", a + i); if(i == 0){ printf("%d ", a[i]); st.erase(a[i]); } else{ if(st.find(a[i]) != st.end()){ if(a[i] > a[i - 1]){ printf("%d ", a[i]); st.erase(a[i]); printf("%d ", *(st.rbegin())); st.erase(*st.rbegin()); }else if(a[i] < a[i - 1]){ printf("%d ", a[i]); st.erase(a[i]); printf("%d ", *(st.begin())); st.erase(st.begin()); } } else{ if(a[i] == a[i - 1]){ printf("%d ", *st.begin()); st.erase(st.begin()); printf("%d ", *(st.rbegin())); st.erase(*st.rbegin()); }else if(a[i] < a[i - 1]){ printf("%d ", *st.begin()); st.erase(st.begin()); printf("%d ", *st.begin()); st.erase(st.begin()); }else{ printf("%d ", *st.rbegin()); st.erase(*st.rbegin()); printf("%d ", *st.rbegin()); st.erase(*st.rbegin()); } } } } }

Compilation message (stderr)

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