結果

問題 No.393 2本の竹
ユーザー rapurasurapurasu
提出日時 2016-07-12 15:59:09
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,678 bytes
コンパイル時間 1,569 ms
使用メモリ 27,320 KB
最終ジャッジ日時 2022-12-14 14:23:00
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 44 ms
21,804 KB
testcase_01 AC 12 ms
7,444 KB
testcase_02 AC 43 ms
23,376 KB
testcase_03 AC 32 ms
13,164 KB
testcase_04 AC 19 ms
12,440 KB
testcase_05 AC 22 ms
10,488 KB
testcase_06 AC 16 ms
8,472 KB
testcase_07 AC 33 ms
11,992 KB
testcase_08 AC 64 ms
17,916 KB
testcase_09 AC 96 ms
26,052 KB
testcase_10 AC 22 ms
10,096 KB
testcase_11 AC 44 ms
13,160 KB
testcase_12 AC 50 ms
15,176 KB
testcase_13 AC 39 ms
12,912 KB
testcase_14 AC 32 ms
11,988 KB
testcase_15 AC 7 ms
8,984 KB
testcase_16 RE -
testcase_17 AC 62 ms
17,896 KB
testcase_18 AC 29 ms
12,376 KB
testcase_19 AC 10 ms
7,848 KB
testcase_20 AC 15 ms
8,184 KB
testcase_21 AC 34 ms
19,504 KB
testcase_22 AC 49 ms
13,944 KB
testcase_23 AC 28 ms
12,912 KB
testcase_24 AC 19 ms
9,376 KB
testcase_25 AC 16 ms
7,836 KB
testcase_26 AC 12 ms
8,228 KB
testcase_27 AC 95 ms
27,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
LL n1[11];
LL n2[11];
LL m[11];
LL A[11][70];
LL ans;

int dp[62][100001];


 
int main(){
    int d;
    cin>>d;
    REP(i,d){
        cin>>n1[i]>>n2[i];
        cin>>m[i];
        REP(j,m[i]){
            cin>>A[i][j];
        }
    }
    REP(i,d){
        ans=0;
        vector<int> v;
        LL nn1=n1[i];
        LL nn2=n2[i];
        LL mm=m[i];
        REP(j,m[i]){
            v.push_back(A[i][j]);
        }
        sort(v.begin(),v.end());
        vector<int>s(60,0);
        REP(j,m[i]){
            if(j==0){
                s[0]=v[0];
            }else{
                s[j]=s[j-1]+v[j];
            }
        }
        int check=0;
        REP(j,m[i]){
            check++;
            if(s[j]>nn1+nn2){
                 break;
            }
        }
        REP(j,check+1){
            REP(k,100001){
                dp[j][k]=0;
            }
        }
        dp[0][0]=1;
        for(int j=1;j<check+1;j++){
            for(int k=0;k<100001;k++){
               if(dp[j-1][k]==1){
                  dp[j][k]=1;
               }
               if((dp[j-1][k]==1)&&(k+v[j-1]<100001)){
                   dp[j][k+v[j-1]]=1;
               }
            }
        }
        bool p=false;
        for(int j=check;j>=0;j--){
            for(int k=s[j-1]-nn1;k<=nn2;k++){
                  if(dp[j][k]==1){
                        cout<<j<<endl;
                        p=true;
                        break;
                  }
            }
            if(p==true){
                  break;
            }
        }
    }
}
0