結果
問題 | No.10 +か×か |
ユーザー |
![]() |
提出日時 | 2015-07-17 18:47:20 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 908 bytes |
コンパイル時間 | 731 ms |
コンパイル使用メモリ | 85,712 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-08 08:25:55 |
合計ジャッジ時間 | 2,931 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 3 ms
5,376 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
ソースコード
#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[550][55]; std::string dfs(int now, int idx, string const& str) { auto& ret = dp[now][idx]; if(!ret.empty()) { return ret; } ret = "1111111111111111111111111111111111111111111111111111111111111111111111"; if(idx == N) { if(tot != now) { return ret; } return ret = str; } return ret = min(dfs(now+A[idx], idx+1, str + "0"), dfs(now*A[idx], idx+1, str + "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; }