結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2020-03-31 07:53:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 5,000 ms |
| コード長 | 527 bytes |
| コンパイル時間 | 1,126 ms |
| コンパイル使用メモリ | 111,420 KB |
| 実行使用メモリ | 26,872 KB |
| 最終ジャッジ日時 | 2024-06-23 21:17:27 |
| 合計ジャッジ時間 | 3,006 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
public class Program
{
static void Main()
{
int l = int.Parse(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
int[] w = Array.ConvertAll(Console.ReadLine().Split(' '), s => int.Parse(s));
Array.Sort(w);
int sum = 0;
int count = 0;
foreach (int a in w)
{
if (sum + a > l)
{
break;
}
count++;
sum += a;
}
Console.WriteLine(count);
}
}