結果

問題 No.393 2本の竹
ユーザー rapurasurapurasu
提出日時 2016-07-12 15:59:09
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,678 bytes
コンパイル時間 1,555 ms
コンパイル使用メモリ 170,928 KB
実行使用メモリ 27,188 KB
最終ジャッジ日時 2023-08-08 00:09:23
合計ジャッジ時間 3,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
21,916 KB
testcase_01 AC 10 ms
7,564 KB
testcase_02 AC 26 ms
23,836 KB
testcase_03 AC 20 ms
13,584 KB
testcase_04 AC 13 ms
13,616 KB
testcase_05 AC 15 ms
11,620 KB
testcase_06 AC 11 ms
9,516 KB
testcase_07 AC 20 ms
13,604 KB
testcase_08 AC 36 ms
19,800 KB
testcase_09 AC 70 ms
26,348 KB
testcase_10 AC 17 ms
11,876 KB
testcase_11 AC 31 ms
13,676 KB
testcase_12 AC 34 ms
15,632 KB
testcase_13 AC 26 ms
13,680 KB
testcase_14 AC 21 ms
13,588 KB
testcase_15 AC 6 ms
9,524 KB
testcase_16 RE -
testcase_17 AC 23 ms
19,732 KB
testcase_18 AC 13 ms
13,608 KB
testcase_19 AC 8 ms
9,500 KB
testcase_20 AC 11 ms
9,564 KB
testcase_21 AC 20 ms
19,820 KB
testcase_22 AC 37 ms
15,660 KB
testcase_23 AC 19 ms
13,652 KB
testcase_24 AC 14 ms
9,644 KB
testcase_25 AC 12 ms
9,696 KB
testcase_26 AC 9 ms
9,548 KB
testcase_27 AC 64 ms
27,188 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