結果
| 問題 |
No.393 2本の竹
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-07-12 01:10:12 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 187 ms / 1,000 ms |
| コード長 | 1,437 bytes |
| コンパイル時間 | 1,285 ms |
| コンパイル使用メモリ | 107,008 KB |
| 実行使用メモリ | 18,088 KB |
| 最終ジャッジ日時 | 2024-11-08 05:33:36 |
| 合計ジャッジ時間 | 3,640 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));}
}
kuuso1