結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-20 17:57:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 754 ms / 5,000 ms |
| コード長 | 1,114 bytes |
| コンパイル時間 | 1,822 ms |
| コンパイル使用メモリ | 172,304 KB |
| 実行使用メモリ | 30,848 KB |
| 最終ジャッジ日時 | 2024-12-14 15:37:01 |
| 合計ジャッジ時間 | 4,765 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
string dp[100001],newdp[100001];
int main()
{
int n,total;
cin >>n >>total;
vector<int> a(n);
rep(i,n) cin >>a[i];
fill(dp,dp+total+1,"#");
dp[a[0]]="";
for(int i=1; i<n; ++i)
{
fill(newdp,newdp+total+1,"#");
for(int j=1; j<=total; ++j)
{
int nxt=j+a[i];
if(nxt<=total)
{
if(newdp[nxt]=="#") newdp[nxt]=dp[j]+"+";
else newdp[nxt]=max(newdp[nxt],dp[j]+"+");
}
nxt=j*a[i];
if(nxt<=total)
{
if(newdp[nxt]=="#") newdp[nxt]=dp[j]+"*";
else newdp[nxt]=max(newdp[nxt],dp[j]+"*");
}
}
rep(j,total+1) dp[j]=newdp[j];
}
cout << dp[total] << endl;
return 0;
}