結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-06-07 13:47:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,504 bytes |
コンパイル時間 | 983 ms |
コンパイル使用メモリ | 112,848 KB |
実行使用メモリ | 25,844 KB |
最終ジャッジ日時 | 2024-06-30 10:28:46 |
合計ジャッジ時間 | 3,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 RE * 29 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Yukicorder { class BlockOfNumber { public static void Main(String[] args) { int L = Input(1, 10000); int N = Input(1, 10000); int[] W = new int[N]; for(int i = 0; i < N; i++) { W[i] = Input(1, L); } int Result = Processing(L, N, W); Console.WriteLine(Result); } public static int Input(int Min , int Max) { int Number = int.Parse(Console.ReadLine()); try { if (Number < Min || Number > Max) { Console.WriteLine(Min + "以上" + Max + "以下で入力してください"); Environment.Exit(0); } }catch (Exception){ Console.WriteLine("想定外のエラーです"); Environment.Exit(0); } return Number; } public static int Processing(int L , int N , int[] W) { int Sum = 0; int Count = 0; for (int i = 0; i < N; i++) { if (L >= Sum + W[i]) { Sum += W[i]; Count++; }else{ break; } } return Count; } } }