結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-25 14:05:27 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,407 bytes |
| コンパイル時間 | 1,306 ms |
| コンパイル使用メモリ | 102,784 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-09-20 14:46:41 |
| 合計ジャッジ時間 | 4,048 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
namespace yukicoder
{
class Program
{
static void Main(string[] args)
{
//大きな箱の幅
int L = int.Parse(Console.ReadLine());
//箱の数
int N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(' ');
int[] a = new int[str.Length];
//各箱の幅
for (int i = 0; i < N; i++)
{
int W = int.Parse(str[i]);
a[i] = W;
}
//小さい順
for (int j = 0; j < a.Length; j++)
{
if(j==a.Length)
{
a[j] = a.Length;
}
for (int i = 0; i < j; i++)
{
if (a[i] > a[i + 1])
{
int temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
}
//判定
int num = L;
int count = 0;
for (int i = 0; i < str.Length; i++)
{
if (num >= 0 && num >= a[i])
{
num = num - a[i];
count++;
}
}
Console.WriteLine(count.ToString());
}
}
}