結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-29 11:28:51 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 744 bytes |
| コンパイル時間 | 8,116 ms |
| コンパイル使用メモリ | 170,268 KB |
| 実行使用メモリ | 179,280 KB |
| 最終ジャッジ日時 | 2025-10-29 11:29:02 |
| 合計ジャッジ時間 | 10,337 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 34 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (104 ミリ秒)。 /home/judge/data/code/Main.cs(1,13): warning CS7022: プログラムのエントリ ポイントは、グローバル コードです。エントリ ポイント 'Main(string[])' を無視します。 [/home/judge/data/code/main.csproj] /home/judge/data/code/Main.cs(1,13): warning CS8321: ローカル関数 'Main' は宣言されていますが、一度も使用されていません [/home/judge/data/code/main.csproj] main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
static void Main(string[] args)
{
string inputWidth = Console.ReadLine()!;
string inputCount = Console.ReadLine()!;
string[] inputBlock = Console.ReadLine()!.Split(' ');
int width = int.Parse(inputWidth);
int count = int.Parse(inputCount);
int[] blockArray = new int[inputBlock.Length];
for (int i = 0; i < inputBlock.Length; i++)
{
blockArray[i] = int.Parse(inputBlock[i]);
}
Array.Sort(blockArray);
int output = 0;
int sum = 0;
for (int i = 0; i < blockArray.Length; i++)
{
sum = sum + blockArray[i];
if (sum < width)
{
output++;
}
else
{
Console.WriteLine(output);
break;
}
}
}