結果
| 問題 | No.10 +か×か |
| コンテスト | |
| ユーザー |
kyuna
|
| 提出日時 | 2020-05-02 01:05:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 775 bytes |
| 記録 | |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 79,452 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-14 15:44:35 |
| 合計ジャッジ時間 | 2,734 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 12 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;
template<class T> inline bool chmax(T &a, T b) { return a < b ? (a = b, 1) : 0; }
int main() {
assert("*" < "+" && "+" < "@");
int n; cin >> n;
int total; cin >> total;
vector<int> a(n);
for (auto &ai: a) cin >> ai;
vector<vector<string>> dp(n, vector<string>(total + 1));
dp[0][a[0]] = "@";
for (int i = 0; i + 1 < n; i++) for (int j = 0; j <= total; j++) {
if (j + a[i + 1] <= total) {
chmax(dp[i + 1][j + a[i + 1]], dp[i][j] + "+");
}
if (j * a[i + 1] <= total) {
chmax(dp[i + 1][j * a[i + 1]], dp[i][j] + "*");
}
}
cout << dp.back()[total].substr(1) << endl;
return 0;
}
kyuna