結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2020-05-03 15:41:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 893 bytes |
| コンパイル時間 | 1,621 ms |
| コンパイル使用メモリ | 169,364 KB |
| 実行使用メモリ | 22,604 KB |
| 最終ジャッジ日時 | 2024-06-12 19:11:12 |
| 合計ジャッジ時間 | 2,389 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int memo[51][100010];
int main() {
int N, Total, A[60];
cin >> N >> Total;
for (int i = 0; i < N; i++)
cin >> A[i];
memo[0][A[0]] = 1;
for (int i = 1; i < N; i++) {
for (int x = 0; x <= Total; x++) {
if (memo[i - 1][x]) {
if (A[i] + x <= Total) {
memo[i][x + A[i]] = 1;
}
if (A[i] * x <= Total && !memo[i][x * A[i]]) {
memo[i][x * A[i]] = 2;
}
}
}
}
string ans;
int tot = Total;
for (int i = N - 1; i > 0; i--) {
if (memo[i][tot] == 1) {
ans.push_back('+');
tot -= A[i];
} else {
ans.push_back('*');
tot /= A[i];
}
}
reverse(ans.end(), ans.begin());
cout << ans << endl;
}
maine_honzuki