結果

問題 No.490 yukiソート
ユーザー 14番
提出日時 2017-03-10 22:40:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 1,634 bytes
コンパイル時間 1,035 ms
コンパイル使用メモリ 113,648 KB
実行使用メモリ 27,788 KB
最終ジャッジ日時 2024-06-24 10:09:07
合計ジャッジ時間 3,609 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
プレゼンテーションモードにする

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
public class Program
{
public void Proc() {
Reader.IsDebug = false;
int n = int.Parse(Reader.ReadLine());
long[] arr = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).ToArray();
for(int i=1; i<2*n-3; i++) {
for(int j=0; j<n; j++) {
int idx1 = j;
int idx2 = i-j;
if(idx2 < idx1) {
break;
}
if(idx2 >= n) {
continue;
}
if(arr[idx1] > arr[idx2]) {
Swap(arr, idx1, idx2);
}
}
}
Console.WriteLine(string.Join(" ", arr));
}
private void Swap(long[] arr, int idx1, int idx2) {
long num = arr[idx1];
arr[idx1] = arr[idx2];
arr[idx2] = num;
}
public class Reader {
public static bool IsDebug = true;
private static System.IO.StringReader SReader;
private static string InitText = @"
15
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9
";
public static string ReadLine() {
if(IsDebug) {
if(SReader == null) {
SReader = new System.IO.StringReader(InitText.Trim());
}
return SReader.ReadLine();
} else {
return Console.ReadLine();
}
}
}
public static void Main(string[] args)
{
Program prg = new Program();
prg.Proc();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0