結果
問題 | No.10 +か×か |
ユーザー | moti |
提出日時 | 2015-07-25 00:24:52 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 712 ms |
コンパイル使用メモリ | 79,224 KB |
実行使用メモリ | 231,332 KB |
最終ジャッジ日時 | 2023-09-23 02:58:41 |
合計ジャッジ時間 | 6,874 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
176,916 KB |
testcase_01 | AC | 69 ms
177,180 KB |
testcase_02 | AC | 70 ms
176,956 KB |
testcase_03 | RE | - |
testcase_04 | WA | - |
testcase_05 | AC | 74 ms
177,116 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
ソースコード
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <complex> #include <queue> #include <set> #include <map> using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) typedef long long ll; int N, tot; vector<int> A; std::string dp[101000][55]; std::string dfs(int now, int idx) { auto& ret = dp[now][idx]; if(!ret.empty()) { return ret; } ret = "1"; rep(i, 55) ret += "1"; if(idx == N) { if(tot != now) { return ret; } return ret = ""; } return ret = min(dfs(now+A[idx], idx+1) + "0", dfs(now*A[idx], idx+1) + "1"); } int main() { cin >> N >> tot; rep(i, N) { int a; cin >> a; A.push_back(a); } auto ans = dfs(A[0], 1); rep(i, ans.size()) { cout << (ans[i] == '0' ? '+' : '*'); } cout << endl; return 0; }