Submission #368443

#TimeUsernameProblemLanguageResultExecution timeMemory
368443cpp219medians (balkan11_medians)C++14
5 / 100
58 ms19564 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 2e3 + 9; const ll inf = 1e16 + 7; typedef pair<int,int> LL; vector<ll> ans; set<ll> s; ll n,b[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n; for (ll i = 1;i <= 2*n - 1;i++) s.insert(i); for (ll i = 1;i <= n;i++) cin>>b[i],s.erase(b[i]); ans.push_back(b[1]); for (ll i = 2;i <= n;i++){ if (b[i] != b[i - 1]) ans.push_back(b[i]); if (b[i - 1] >= b[i]) ans.push_back(*s.begin()),s.erase(s.begin()); if (b[i - 1] <= b[i]) ans.push_back(*prev(s.end())),s.erase(prev(s.end())); } for (auto i : ans) cout<<i<<" "; }

Compilation message (stderr)

medians.cpp: In function 'int main()':
medians.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...