結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2020-03-24 23:17:27 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 576 bytes |
| コンパイル時間 | 1,009 ms |
| コンパイル使用メモリ | 110,456 KB |
| 実行使用メモリ | 28,620 KB |
| 最終ジャッジ日時 | 2025-01-01 18:53:39 |
| 合計ジャッジ時間 | 3,364 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
using System.Linq;
public class P0005 {
public static void Main() {
var l = int.Parse(Console.ReadLine().Trim());
var n = int.Parse(Console.ReadLine().Trim());
var ws = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList();
ws.Sort();
int count = n;
int len = 0;
for (var i=0; i<n; i++) {
if (len + ws[i] <= l) {
len += ws[i];
} else {
count = i;
break;
}
}
Console.WriteLine(count);
}
}