結果

問題 No.490 yukiソート
ユーザー chacoder1chacoder1
提出日時 2021-02-07 10:50:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 2,382 ms
コンパイル使用メモリ 191,708 KB
最終ジャッジ日時 2025-01-18 13:46:28
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
  int n;
  cin>>n;
  int A[n];
  rep(i,n) cin>>A[i];
  for(int i=1;i<2*n-3;i++){
    for(int p=0;p<=i;p++){
      int q=i-p;
      if(p>n-1) continue;
      if(q>n-1) continue;
      if(p>=q) continue;
      //cout<<p<<" "<<q<<endl;
      if(A[p]>A[q]){
        int temp=A[p];
        A[p]=A[q];
        A[q]=temp;
      }
    }
  }
  rep(i,n){
    if(i != 0){
      cout<<" ";
    }
    cout<<A[i];
  }
  cout<<endl;
  return 0;
}
0