結果
問題 |
No.10 +か×か
|
ユーザー |
|
提出日時 | 2019-02-05 15:21:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 683 ms / 5,000 ms |
コード長 | 928 bytes |
コンパイル時間 | 760 ms |
コンパイル使用メモリ | 84,964 KB |
実行使用メモリ | 306,932 KB |
最終ジャッジ日時 | 2024-12-14 15:41:53 |
合計ジャッジ時間 | 3,674 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include<stdio.h> #include<iostream> #include<iomanip> #include<math.h> #include<algorithm> #include<utility> #include<queue> #include<string.h> #include<string> #include<set> #include<functional> using namespace std; typedef long long LL; typedef pair<int, int> P; typedef queue<P> Q; int N,T,a[51]; string dp[51][100010]={}; int main(){ cin >>N>>T; for(int i=0;i<N;i++){ cin >> a[i]; } for(int i=0;i<N;i++){ for(int j=0;j<=T;j++){ dp[i][j]="&"; } } dp[0][a[0]]=""; for(int i=1;i<N;i++){ for(int j=1;j<=T;j++){ if(dp[i-1][j]!="&"){ if(j+a[i]<=T){ dp[i][j+a[i]]=max(dp[i-1][j]+"+",dp[i][j+a[i]]); } if(j*a[i]<=T){ dp[i][j*a[i]]=max(dp[i-1][j]+"*",dp[i][j*a[i]]); } } } } cout<<dp[N-1][T]<<endl; return 0; }