結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-24 23:17:27 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 5,000 ms |
| コード長 | 576 bytes |
| 記録 | |
| コンパイル時間 | 4,269 ms |
| コンパイル使用メモリ | 104,064 KB |
| 実行使用メモリ | 20,992 KB |
| 最終ジャッジ日時 | 2026-06-05 14:41:44 |
| 合計ジャッジ時間 | 5,072 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
}
}