Submission #854334

#TimeUsernameProblemLanguageResultExecution timeMemory
854334JoksimKaktusmedians (balkan11_medians)C++17
5 / 100
19 ms2472 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int n; cin >> n; bool arr[n*2]; for(int i = 0;i < n*2;i++){ arr[i] = false; } int x; cin >> x; cout << x << " "; arr[x] = true; int l = 1; if(x == 1) l++; int r = 2*n-1; if(x == r) r--; int last = x; for(int i = 1;i < n;i++){ cin >> x; if(x == last){ cout << l << " " << r << " "; arr[l] = true; while(arr[l]){ l++; } arr[r] = true; while(arr[r]){ r--; } }else if(x > last){ cout << x << " " << r << " "; arr[x] = true; arr[r] = true; while(arr[r]){ r--; } }else{ cout << x << " " << l << " "; arr[x] = true; arr[l] = true; while(arr[l]){ l++; } } last = x; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...