結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-11-17 09:32:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 356 ms / 5,000 ms |
コード長 | 1,152 bytes |
コンパイル時間 | 917 ms |
コンパイル使用メモリ | 110,788 KB |
実行使用メモリ | 26,980 KB |
最終ジャッジ日時 | 2024-09-25 05:46:18 |
合計ジャッジ時間 | 5,014 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; namespace ConsoleApp11 { class Program { static void Main(string[] args) { int tem; int count = 0; int L = int.Parse(Console.ReadLine()); int N = int.Parse(Console.ReadLine()); var input = Console.ReadLine().Split(' '); int[] W = new int[N]; for(int i = 0; i < N; i++) { W[i] = int.Parse(input[i]); } for(int i = 0; i < N - 1; i++) { for(int j = i + 1; j < N; j++) { if(W[i] > W[j]) { tem = W[j]; W[j] = W[i]; W[i] = tem; } } } for(int i = 0; i < N; i++) { L = L - W[i]; if(L >= 0) { count++; } else if(L < 0) { break; } } Console.WriteLine(count); } } }