結果

問題 No.393 2本の竹
ユーザー kuuso1kuuso1
提出日時 2016-07-12 01:10:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 225 ms / 1,000 ms
コード長 1,437 bytes
コンパイル時間 3,770 ms
コンパイル使用メモリ 111,388 KB
実行使用メモリ 24,764 KB
最終ジャッジ日時 2023-08-07 23:59:53
合計ジャッジ時間 7,632 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
20,616 KB
testcase_01 AC 60 ms
20,756 KB
testcase_02 AC 60 ms
20,840 KB
testcase_03 AC 61 ms
24,764 KB
testcase_04 AC 59 ms
20,840 KB
testcase_05 AC 59 ms
20,692 KB
testcase_06 AC 59 ms
20,768 KB
testcase_07 AC 60 ms
20,732 KB
testcase_08 AC 62 ms
20,608 KB
testcase_09 AC 225 ms
20,808 KB
testcase_10 AC 97 ms
20,688 KB
testcase_11 AC 122 ms
20,724 KB
testcase_12 AC 127 ms
20,680 KB
testcase_13 AC 105 ms
22,716 KB
testcase_14 AC 90 ms
20,680 KB
testcase_15 AC 73 ms
22,816 KB
testcase_16 AC 99 ms
20,700 KB
testcase_17 AC 60 ms
20,868 KB
testcase_18 AC 59 ms
20,748 KB
testcase_19 AC 60 ms
22,716 KB
testcase_20 AC 60 ms
22,712 KB
testcase_21 AC 61 ms
20,612 KB
testcase_22 AC 141 ms
20,612 KB
testcase_23 AC 99 ms
20,852 KB
testcase_24 AC 63 ms
20,764 KB
testcase_25 AC 61 ms
20,764 KB
testcase_26 AC 58 ms
20,788 KB
testcase_27 AC 195 ms
20,800 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(;T>0;T--){
			int N1,N2;
			var d = ria();
			N1 = d[0]; N2 = d[1];
			int M = ri();
			int[] A = ria();
			Array.Sort(A);
			long sum = 0;
			
			bool[] dp = new bool[N1+1];
			
			dp[0] = true;
			int ans = 0;
			
			for(int i=0;i<M;i++){
				sum += A[i];
				for(int j=N1;j>=0;j--){
					if(!dp[j])continue;
					if(j+A[i] <=N1){
						dp[j+A[i]] = true;
					}
				}
				
				for(int j=0;j<=N1;j++){
					if(!dp[j])continue;
					if( sum - j <= N2){
						ans = Math.Max(ans,i+1);
					}
				}
			}
			Console.WriteLine(ans);
		}
		
	}
	int T;
	public Sol(){
		T = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0