結果
問題 | No.39 桁の数字を入れ替え |
ユーザー | suzu |
提出日時 | 2023-05-16 13:05:57 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 57 ms / 5,000 ms |
コード長 | 908 bytes |
コンパイル時間 | 3,574 ms |
コンパイル使用メモリ | 104,036 KB |
実行使用メモリ | 22,620 KB |
最終ジャッジ日時 | 2023-08-21 05:09:50 |
合計ジャッジ時間 | 5,440 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
20,560 KB |
testcase_01 | AC | 56 ms
20,668 KB |
testcase_02 | AC | 55 ms
18,496 KB |
testcase_03 | AC | 56 ms
22,620 KB |
testcase_04 | AC | 56 ms
20,488 KB |
testcase_05 | AC | 56 ms
22,608 KB |
testcase_06 | AC | 56 ms
20,672 KB |
testcase_07 | AC | 56 ms
20,676 KB |
testcase_08 | AC | 56 ms
20,556 KB |
testcase_09 | AC | 56 ms
20,468 KB |
testcase_10 | AC | 56 ms
20,552 KB |
testcase_11 | AC | 56 ms
20,564 KB |
testcase_12 | AC | 56 ms
20,560 KB |
testcase_13 | AC | 57 ms
20,628 KB |
testcase_14 | AC | 57 ms
20,476 KB |
testcase_15 | AC | 57 ms
22,528 KB |
testcase_16 | AC | 56 ms
20,632 KB |
testcase_17 | AC | 56 ms
22,544 KB |
testcase_18 | AC | 56 ms
20,592 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; namespace yukicoder { class Programs { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var list = new List<int>(); int tn = N; while(tn > 0) { list.Add(tn % 10); tn /= 10; } list.Reverse(); for(int p = 0;p < list.Count - 1;p++) { int head = list[p]; int max = -1; int maxIndex = -1; for(int q = p + 1;q < list.Count;q++) { int ch = list[q]; if(max <= ch) { max = ch; maxIndex = q; } } if(max == -1 || max <= head) { continue; }else { list[p] = max; list[maxIndex] = head; break; } } list.Reverse(); int sum = 0; int a = 1; foreach(int i in list) { sum += a * i; a *= 10; } Console.WriteLine(sum); } } }