結果
問題 | No.365 ジェンガソート |
ユーザー | SagToki |
提出日時 | 2018-06-11 11:34:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 2,675 bytes |
コンパイル時間 | 3,816 ms |
コンパイル使用メモリ | 108,188 KB |
実行使用メモリ | 28,920 KB |
最終ジャッジ日時 | 2023-09-13 02:54:46 |
合計ジャッジ時間 | 8,045 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
20,692 KB |
testcase_01 | AC | 56 ms
20,672 KB |
testcase_02 | AC | 57 ms
20,724 KB |
testcase_03 | AC | 57 ms
20,716 KB |
testcase_04 | AC | 58 ms
22,796 KB |
testcase_05 | AC | 57 ms
20,704 KB |
testcase_06 | AC | 57 ms
22,712 KB |
testcase_07 | AC | 56 ms
20,816 KB |
testcase_08 | AC | 56 ms
20,904 KB |
testcase_09 | AC | 56 ms
20,732 KB |
testcase_10 | AC | 56 ms
20,748 KB |
testcase_11 | AC | 57 ms
20,696 KB |
testcase_12 | AC | 57 ms
20,696 KB |
testcase_13 | AC | 56 ms
20,748 KB |
testcase_14 | AC | 57 ms
20,756 KB |
testcase_15 | AC | 57 ms
20,684 KB |
testcase_16 | AC | 106 ms
28,064 KB |
testcase_17 | AC | 116 ms
26,664 KB |
testcase_18 | AC | 68 ms
21,212 KB |
testcase_19 | AC | 114 ms
26,548 KB |
testcase_20 | AC | 81 ms
23,816 KB |
testcase_21 | AC | 76 ms
21,744 KB |
testcase_22 | AC | 105 ms
26,060 KB |
testcase_23 | AC | 89 ms
24,792 KB |
testcase_24 | AC | 104 ms
25,844 KB |
testcase_25 | AC | 76 ms
21,908 KB |
testcase_26 | AC | 95 ms
22,940 KB |
testcase_27 | AC | 117 ms
26,804 KB |
testcase_28 | AC | 94 ms
22,804 KB |
testcase_29 | AC | 112 ms
26,484 KB |
testcase_30 | AC | 95 ms
24,876 KB |
testcase_31 | AC | 79 ms
21,668 KB |
testcase_32 | AC | 77 ms
21,864 KB |
testcase_33 | AC | 116 ms
26,928 KB |
testcase_34 | AC | 73 ms
21,668 KB |
testcase_35 | AC | 103 ms
23,948 KB |
testcase_36 | AC | 117 ms
26,860 KB |
testcase_37 | AC | 117 ms
26,948 KB |
testcase_38 | AC | 117 ms
26,992 KB |
testcase_39 | AC | 118 ms
28,920 KB |
testcase_40 | AC | 119 ms
27,012 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; namespace JengaSort { class Program { static void Main(string[] args) { //ブロックの個数をNで定義 int N = InputN(1, 100000); //それぞれのブロックの長さをEachLength配列で定義 int[] EachLength = Input(N, 1, N); int Result = Processing(N , EachLength); int Answer = N - Result; Console.WriteLine(Answer); } //1行目の入力が数字で行われているか、数値は指定の範囲内のものかを判定 static int InputN(int Min , int Max) { int Number = 0; try { Number = int.Parse(Console.ReadLine()); if (Number < Min || Number > Max) { Console.WriteLine(Min + "以上" + Max + "以下で入力してください"); } }catch(FormatException e) { Console.WriteLine("数字を入力してください"); }catch(Exception E) { Console.WriteLine("想定外のエラーです"); } return Number; } //2行目の入力が数字で行われているか、数値は指定の範囲内のものかを判定 static int[] Input(int N ,int Min , int Max) { String[] Numbers = null; try { Numbers = Console.ReadLine().Split(); for(int i = 0; i < N; i++) { if(int.Parse(Numbers[i]) < Min || int.Parse(Numbers[i]) > Max) { Console.WriteLine(Min + "以上" + Max + "以下の数字で入力してください"); } } } catch(Exception E) { Console.WriteLine("想定外のエラーです"); } //String型配列をint型配列に変換 int[] NewNumbers = new int[N]; for (int j = 0; j < N; j++) { NewNumbers[j] = int.Parse(Numbers[j]); } return NewNumbers; } //移動がない数字の個数を計算するメソッド static int Processing(int N , int[] EachLength) { //変動しない数字の個数をCount変数で数える int Count = 0; //変動する最大を更新して所持する変数 int Match = N; for (int i = N - 1; i >= 0; i--) { if(EachLength[i] == Match) { Count++; Match--; } } return Count; } } }