結果
問題 | No.490 yukiソート |
ユーザー |
![]() |
提出日時 | 2019-09-04 09:22:46 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 1,868 ms |
コンパイル使用メモリ | 31,232 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 01:02:15 |
合計ジャッジ時間 | 2,166 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | WA * 34 |
ソースコード
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> int main(void) { int num; int list[5000]={0}; scanf("%d",&num); for(int i=0;i<num;i++) { scanf("%d",&list[i]); } for(int i=0;i<num-1;i++) { for(int j=i+1;j<num;j++) { if(list[i]>list[j]) { int tmp=list[i]; list[i]=list[j]; list[j]=tmp; } } } for(int i=0;i<num;i++) { int p=list[i]; int q=list[i+1]; if(p+q==i&&p>q) { int tmp=list[i]; list[i]=list[i+1]; list[i+1]=tmp; } } for(int i=0;i<num;i++) { printf("%d",list[i]); } }