結果
| 問題 |
No.393 2本の竹
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-31 02:13:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 3,499 ms |
| コンパイル使用メモリ | 198,232 KB |
| 最終ジャッジ日時 | 2025-01-12 08:24:52 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 TLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:8:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | int n1,n2,m; scanf("%d%d%d",&n1,&n2,&m);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | rep(i,m) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:32:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
void solve(){
int n1,n2,m; scanf("%d%d%d",&n1,&n2,&m);
vector<int> a(m);
rep(i,m) scanf("%d",&a[i]);
sort(a.begin(),a.end());
int ans=0;
rep(i,m){
int sum=accumulate(a.begin(),a.begin()+i+1,0);
if(sum>n1+n2) break;
vector<bool> dp(sum+1);
dp[0]=true;
rep(j,i+1){
for(int x=sum;x>=a[j];x--) if(dp[x-a[j]]) dp[x]=true;
}
bool ok=false;
rep(x,n1+1) if(dp[x] && sum-x<=n2) ok=true;
if(ok) ans=i+1;
}
printf("%d\n",ans);
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}