結果

問題 No.10 +か×か
ユーザー roiti46roiti46
提出日時 2015-10-11 06:10:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 145,648 KB
実行使用メモリ 42,536 KB
最終ジャッジ日時 2023-09-28 11:39:00
合計ジャッジ時間 2,135 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,392 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 8 ms
40,216 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 10 ms
19,452 KB
testcase_10 AC 2 ms
7,500 KB
testcase_11 AC 2 ms
5,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())

int N, T;
int A[51];
ll dp[51][100005];

int main(void) {
  cin >> N;
  cin >> T;
  rep(i, N) cin >> A[i];
  rep(i, N) rep(j, T + 1) dp[i][j] = 1LL << 51;
  dp[0][A[0]] = 0;
  REP(i, 1, N) rep(j, T + 1) {
    if (j + A[i] <= T) dp[i][j + A[i]] = min(dp[i][j + A[i]], dp[i - 1][j]);
    if (j * A[i] <= T) dp[i][j * A[i]] = min(dp[i][j * A[i]], dp[i - 1][j] | 1LL << (i - 1));
  }

  string ans;
  rep(i, N - 1) ans += (dp[N - 1][T] >> i & 1 ? '*':'+');
  cout << ans << endl;
  return 0;
}
0