結果

問題 No.10 +か×か
ユーザー parukiparuki
提出日時 2016-09-30 01:33:29
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 617 ms / 5,000 ms
コード長 921 bytes
コンパイル時間 2,224 ms
コンパイル使用メモリ 170,036 KB
実行使用メモリ 306,824 KB
最終ジャッジ日時 2023-08-21 06:20:54
合計ジャッジ時間 4,519 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
162,744 KB
testcase_01 AC 58 ms
162,708 KB
testcase_02 AC 58 ms
162,712 KB
testcase_03 AC 617 ms
306,824 KB
testcase_04 AC 101 ms
164,024 KB
testcase_05 AC 59 ms
162,760 KB
testcase_06 AC 614 ms
305,552 KB
testcase_07 AC 267 ms
207,496 KB
testcase_08 AC 98 ms
169,568 KB
testcase_09 AC 97 ms
166,336 KB
testcase_10 AC 60 ms
162,712 KB
testcase_11 AC 60 ms
162,692 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], MI = "!";

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] = MI;
    dp[1][A[0]] = "";
    FOR(i, 1, N)rep(j, T + 1)if(dp[i][j]!=MI){
        int x = j + A[i], y = j*A[i];
        if(x <= T)smax(dp[i + 1][x], dp[i][j] + '+');
        if(y <= T)smax(dp[i + 1][y], dp[i][j] + '*');
    }
    cout << dp[N][T] << endl;
}
0