Submission #480735

#TimeUsernameProblemLanguageResultExecution timeMemory
480735socpitemedians (balkan11_medians)C++14
5 / 100
207 ms1484 KiB
#include<bits/stdc++.h> using namespace std; int currmin, currmax, pre, n, tmp; vector<bool> used; int getmin(){ while(used[currmin])currmin++; return currmin; } int getmax(){ while(used[currmax])currmax--; return currmax; } void query(int x){ cout << x << " "; used[x]=true; } int main(){ cin >> n; used.assign(2*n, false); currmin = 1; currmax = 2*n-1; cin >> tmp; cout << tmp << " "; used[tmp]=true; pre = tmp; for(int i = 0; i < n-1; i++){ cin >> tmp; if(tmp > pre){ query(tmp); query(getmax()); } else if(tmp < pre){ query(tmp); query(getmin()); } else{ query(getmin()); query(getmax()); } pre = tmp; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...