Submission #480737

#TimeUsernameProblemLanguageResultExecution timeMemory
480737socpitemedians (balkan11_medians)C++14
100 / 100
191 ms1560 KiB
#include<bits/stdc++.h> using namespace std; int currmin, currmax, pre, n, tmp; vector<bool> used; vector<int> ans; 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; query(tmp); pre = tmp; for(int i = 0; i < n-1; i++){ cin >> tmp; if(tmp > pre){ if(!used[tmp])query(tmp); else query(getmax()); query(getmax()); } else if(tmp < pre){ if(!used[tmp])query(tmp); else query(getmin()); query(getmin()); } else{ query(getmin()); query(getmax()); } pre = tmp; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...