結果

問題 No.393 2本の竹
ユーザー kuuso1kuuso1
提出日時 2016-07-12 01:10:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 168 ms / 1,000 ms
コード長 1,437 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 112,716 KB
実行使用メモリ 26,480 KB
最終ジャッジ日時 2024-04-25 18:08:27
合計ジャッジ時間 3,477 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,116 KB
testcase_01 AC 23 ms
26,320 KB
testcase_02 AC 23 ms
22,192 KB
testcase_03 AC 24 ms
24,020 KB
testcase_04 AC 23 ms
24,112 KB
testcase_05 AC 23 ms
24,236 KB
testcase_06 AC 23 ms
24,236 KB
testcase_07 AC 25 ms
24,272 KB
testcase_08 AC 27 ms
24,276 KB
testcase_09 AC 168 ms
24,136 KB
testcase_10 AC 61 ms
24,144 KB
testcase_11 AC 86 ms
24,276 KB
testcase_12 AC 91 ms
24,288 KB
testcase_13 AC 67 ms
26,076 KB
testcase_14 AC 53 ms
24,152 KB
testcase_15 AC 39 ms
25,896 KB
testcase_16 AC 58 ms
25,940 KB
testcase_17 AC 27 ms
26,480 KB
testcase_18 AC 27 ms
24,012 KB
testcase_19 AC 27 ms
24,148 KB
testcase_20 AC 27 ms
21,936 KB
testcase_21 AC 26 ms
26,184 KB
testcase_22 AC 101 ms
26,188 KB
testcase_23 AC 64 ms
21,856 KB
testcase_24 AC 28 ms
24,020 KB
testcase_25 AC 28 ms
24,032 KB
testcase_26 AC 26 ms
24,272 KB
testcase_27 AC 151 ms
24,284 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