結果

問題 No.10 +か×か
ユーザー parukiparuki
提出日時 2016-09-30 01:30:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 924 bytes
コンパイル時間 4,058 ms
コンパイル使用メモリ 167,932 KB
実行使用メモリ 306,908 KB
最終ジャッジ日時 2023-08-13 15:12:48
合計ジャッジ時間 5,139 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
162,688 KB
testcase_01 WA -
testcase_02 AC 60 ms
162,712 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 63 ms
162,860 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 99 ms
166,320 KB
testcase_10 AC 62 ms
162,692 KB
testcase_11 AC 61 ms
162,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string dp[51][100001], INF = "~";

int main(){
    int N, T;
    cin >> N >> T;
    vi A(N); rep(i, N)cin >> A[i];
    rep(i, N + 1)rep(j, T + 1)dp[i][j] = INF;
    dp[1][A[0]] = "";
    FOR(i, 1, N)rep(j, T + 1)if(dp[i][j]!=INF){
        int x = j + A[i], y = j*A[i];
        if(x <= T)smin(dp[i + 1][x], dp[i][j] + '+');
        if(y <= T)smin(dp[i + 1][y], dp[i][j] + '*');
    }
    cout << dp[N][T] << endl;
}
0