結果
問題 | No.393 2本の竹 |
ユーザー |
![]() |
提出日時 | 2016-07-12 00:43:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 57 ms / 1,000 ms |
コード長 | 533 bytes |
コンパイル時間 | 1,924 ms |
コンパイル使用メモリ | 172,060 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 05:32:36 |
合計ジャッジ時間 | 3,190 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init; int main(){ int T; cin>>T; while(T--){ int L,R,N; cin>>L>>R>>N; vector<int> a(N); for(auto &it:a)cin>>it; sort(a.begin(),a.end()); int sum=0; int res=0; vector<int> dp(L+1,0); dp[0]=1; for(int i=0;i<N;i++){ sum+=a[i]; for(int j=L;j>=a[i];j--){ dp[j]|=dp[j-a[i]]; } for(int j=0;j<=L;j++) if(dp[j]==1&&sum-j<=R) res=i+1; } cout<<res<<endl; } return 0; }