Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.007 s | 2 KBi |
#3 |
Correcto
|
0.007 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 2 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.298 s | 2 KBi |
#8 |
Correcto
|
0.416 s | 2 KBi |
#9 |
Correcto
|
0.339 s | 2 KBi |
#10 |
Correcto
|
0.456 s | 2 KBi |
#11 |
Correcto
|
0.392 s | 3 KBi |
#12 |
Correcto
|
0.333 s | 3 KBi |
#13 |
Correcto
|
0.34 s | 3 KBi |
#14 |
Correcto
|
0.421 s | 3 KBi |
#15 |
Correcto
|
0.376 s | 3 KBi |
#16 |
Correcto
|
0.426 s | 3 KBi |
#17 |
Correcto
|
0.422 s | 3 KBi |
#18 |
Correcto
|
0.423 s | 3 KBi |
#19 |
Correcto
|
0.377 s | 2 KBi |
#20 |
Correcto
|
0.302 s | 2 KBi |
#21 |
Correcto
|
0.38 s | 2 KBi |
#22 |
Correcto
|
0.293 s | 2 KBi |
#23 |
Correcto
|
0.356 s | 3 KBi |
#24 |
Correcto
|
0.384 s | 2 KBi |
#25 |
Correcto
|
0.308 s | 2 KBi |
#26 |
Correcto
|
0.437 s | 3 KBi |
#27 |
Correcto
|
0.446 s | 3 KBi |
#include <bits/stdc++.h> #define ii pair<int,int> #define F first #define S second #define pb push_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define fore(i, a, b) for(int i = a; i < b; i += 1) #define forr(i, a) for(int i = a; i >= 0; i--) #define sz(s) int(s.size()) #define cls(a,car) memset(a,car,sizeof (a)) #define db(x) cout << #x << " is " << x << '\n' #define angle(x) double(x * acos(-1) / 180.0) using namespace std; void debug(){cout << endl;} template<typename T, typename... Args> void debug(T a, Args... args){cout << a << " "; debug(args...);} typedef long long ll; typedef vector<int> vi; typedef vector<ii> vii; const int N = 2e5 + 5; const ll mod = 1e9 + 7; const double E = 1e-7; const int oo = 1e9; void merge_sort(int l, int r, vector<int> &v){ if(l == r)return; int mid = (l + r) >> 1; merge_sort(l, mid, v); merge_sort(mid + 1, r, v); queue<int> L, R; for(int i = l; i <= mid; i ++) L.push(v[i]); for(int i = mid + 1; i <= r; i++) R.push(v[i]); for(int i = l; i <= r; i++){ if(!sz(L)){ v[i] = R.front(); R.pop(); }else if(!sz(R)){ v[i] = L.front(); L.pop(); }else{ if(R.front() <= L.front()){ v[i] = R.front(); R.pop(); }else{ v[i] = L.front(); L.pop(); } } } } void solve(){ int n; cin >> n; vi v(n); for(auto &i : v)cin >> i; merge_sort(0, n - 1, v); cout << v[0]; for(int i = 1; i < n; i++) cout << ' ' << v[i]; cout << '\n'; } int main(){ #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #endif int t = 1; //cin >> t; for(int i = 1; i <= t; i++) solve(); #ifdef LOCAL cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }