Submission #1315961

#TimeUsernameProblemLanguageResultExecution timeMemory
1315961mpdogemedians (balkan11_medians)C++20
5 / 100
32 ms5628 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> #include <queue> #include <unordered_set> #include <unordered_map> #include <numeric> #include <cmath> // Dla macOs zachowaj includy w przeciwnym wypadku zastąp "#include <bits/stdc++.h> " // szybki kod #define all(v) (v).begin(), (v).end() #define rep(i, a, b) for(int i = a;i <= b; i++) #define per(i, a, b) for(int i = a;i >= b; i--) #define pb push_back #define ins insert #define st first #define nd second #define test int tc; cin>>tc; while(tc--) // struktury danych #define smldi set<map<long double, int > > #define spumldidsi set<pair<unordered_map<long double, int>, deque<set<long long> > > > // funkcje wspomagajace debugowanie programu #define printv(a) { for(auto u : a) cout<<u<<" "; cout<<"/n"; } #define debug(x) cerr << #x << " = " << x << endl; // usingi using namespace std; using ll = long long; using pii = pair<int,int>; using vi = vector<int>; using si = set<int>; using mii = map<int,int>; using bigi = __int128; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,N; cin>>n; N = n*2-1; vector<int> a,b; for(int i=0;i<n;i++){ int c; cin>>c; b.pb(c); } int pref = 1,suf = 0; vector<pair<pair<int,int>,int> > przedz; a.resize(N+1); a[0] = b[0]; for(int i=1;i<n;i++){ if(b[i] > b[i-1]){ przedz.pb({{N-b[i-1],1},i*2-1}); przedz.pb({{N-b[i-1],1},i*2}); } if(b[i] < b[i-1]){ przedz.pb({{b[i-1]-1,0},i*2-1}); przedz.pb({{b[i-1]-1,0},i*2}); } if(b[i] == b[i-1]){ przedz.pb({{b[i-1]-1,0},i*2-1}); przedz.pb({{N-b[i-1],1},i*2}); } } sort(przedz.begin(),przedz.end()); for(int i=0;i<przedz.size();i++){ int dlug,typ,ind; dlug = przedz[i].st.st; typ = przedz[i].st.nd; ind = przedz[i].nd; if(typ==0){ a[ind] = pref; pref++; }else{ a[ind] = N - suf; suf++; } } for(int i=0;i<N;i++){ cout<<a[i]<<" "; } cout<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...