結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
mayoko_
|
| 提出日時 | 2014-12-11 17:36:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,219 bytes |
| コンパイル時間 | 611 ms |
| コンパイル使用メモリ | 76,228 KB |
| 実行使用メモリ | 353,912 KB |
| 最終ジャッジ日時 | 2024-06-11 20:35:40 |
| 合計ジャッジ時間 | 3,470 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 1 |
ソースコード
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
using namespace std;
typedef long long ll;
const int MAXN = 64;
string dp[MAXN][100100];
int a[MAXN];
int main(void) {
int N, Total;
cin >> N;
cin >> Total;
for (int i = 0; i < N; i++) {
cin >> a[i];
}
if (a[0] + a[1] != 0) {
dp[0][a[0]+a[1]] = "+";
dp[0][a[0]*a[1]] = "*";
} else {
dp[0][a[0]+a[1]] = "+";
}
for (int i = 0; i < N-1; i++) {
for (int j = 1; j <= Total; j++) {
if (!dp[i][j].empty()) {
int tmp = j * a[i+2];
if (tmp <= Total) {
dp[i+1][tmp] = max(dp[i+1][tmp], dp[i][j]+"*");
}
tmp = j + a[i+2];
if (tmp <= Total) {
dp[i+1][tmp] = max(dp[i+1][tmp], dp[i][j]+"+");
}
}
}
}
cout << dp[N-2][Total] << endl;
return 0;
}
mayoko_