結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2017-03-10 22:52:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 1,969 bytes |
コンパイル時間 | 818 ms |
コンパイル使用メモリ | 95,612 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 10:15:05 |
合計ジャッジ時間 | 1,970 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
#include <iostream> #include <iomanip> #include <string> #include <vector> #include <queue> #include <algorithm> #include <utility> #include <cmath> #include <map> #include <set> #include <stack> #include <cstdio> #include <cstdlib> #include <cstring> #define INF_LL 1e18 #define INF 1e9 #define REP(i, n) for(int i = 0;i < (n);i++) #define FOR(i, a, b) for(int i = (a);i < (b);i++) #define all(x) x.begin(),x.end() using namespace std; using ll = long long; using PII = pair<int, int>; template<typename T> void chmax(T &a, T &b){ a = max(a, b); } template<typename T> void chmin(T &a, T &b){ a = min(a, b); } class Union_find{ private: vector<int> par; vector<int> rank; int n; public: Union_find(int a){ n = a; for(int i = 0;i < n;i++){ par.push_back(i); rank.push_back(0); } } int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } } void unite(int x, int y){ x = find(x); y = find(y); if(x == y) return; if(rank[x] < rank[y]){ par[x] = y; }else{ par[y] = x; if(rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y){ return find(x) == find(y); } }; class RMQ{ vector<int> dat; int n; public: RMQ(int n_){ n = 1; while(n < n_) n *= 2; REP(i, n*2-1){ dat.push_back(INF); } } void update(int x, int i){ i += n-1; dat[i] = x; while(i > 0){ i = (i-1)/2; dat[i] = min(dat[i*2+1], dat[i*2+2]); } } int query(int a, int b, int l, int r, int k){ if(a <= l && r <= b) return dat[k]; if(b <= l || r <= a) return INF; return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2, r, k*2+2)); } int query(int a, int b){ return query(a, b, 0, n, 0); } }; int main(void){ int n; ll a[5145]; vector<int> b; cin >> n; REP(i, n){ cin >> a[i]; } int p = 0; FOR(i, 1, 2*n-3){ REP(j, (i+1)/2){ if(i-j < n && a[j] > a[i-j]){ swap(a[j], a[i-j]); } } } REP(i, n){ cout << a[i] << " "; } cout << endl; }