結果

問題 No.5 数字のブロック
ユーザー isimiyaisimiya
提出日時 2018-06-04 22:34:00
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 63,568 KB
実行使用メモリ 23,264 KB
最終ジャッジ日時 2023-09-12 22:17:51
合計ジャッジ時間 4,417 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 55 ms
20,556 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 57 ms
22,676 KB
testcase_21 AC 58 ms
20,560 KB
testcase_22 AC 57 ms
20,580 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 58 ms
20,556 KB
testcase_27 AC 57 ms
20,688 KB
testcase_28 AC 56 ms
20,568 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 55 ms
20,684 KB
testcase_32 AC 55 ms
20,620 KB
testcase_33 AC 55 ms
22,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
	public static void Main(string[] args)
	{
	    long x = 0;
	    long i = 0;
	    
	    string stdin = Console.ReadLine();
	    long L = long.Parse(stdin);
	    
	    stdin = Console.ReadLine();
	    long N = long.Parse(stdin);
	    
        stdin = Console.ReadLine();
		string[] c = stdin.Split(' ');
		long[] w = new long[N];
		for(i = 0; i < N; i++){
    		w[i] = long.Parse(c[i]);
		}
		
		Array.Sort(w);
		i = 0;
		while((x <= L) && i < N){
		    x += w[i];
		    i++;
		}
		
		Console.WriteLine(i);
	}
}
0