結果
| 問題 | No.332 数列をプレゼントに |
| コンテスト | |
| ユーザー |
izryt(趣味)
|
| 提出日時 | 2016-12-28 11:04:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,241 bytes |
| 記録 | |
| コンパイル時間 | 746 ms |
| コンパイル使用メモリ | 87,268 KB |
| 実行使用メモリ | 500,932 KB |
| 最終ジャッジ日時 | 2024-12-15 07:37:12 |
| 合計ジャッジ時間 | 61,913 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 MLE * 1 |
| other | AC * 18 TLE * 11 MLE * 13 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <tuple>
using namespace std;
#define rep(i,x) for(int i=0;i<x;++i)
template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.first<<", "<<p.second<<")";return os;}
using int64 = long long;
using data = pair<int64, int>;
map<int64, data> dp;
int64 N, X;
int A[105];
string ans = "";
int main()
{
cin >> N >> X;
rep(i, N) cin >> A[i], ans += "x";
dp[0] = data(-1, -1);
rep(i, N) {
int len = dp.size();
vector<pair<int64, data>> hoge;
for (auto it = begin(dp); it != end(dp); ++it) {
hoge.emplace_back(it->first, it->second);
}
//cout << "debug:\n";
rep(j, hoge.size()) {
int64 v = hoge[j].first;
data info = hoge[j].second;
if (dp.find(v + A[i]) == end(dp)) {
dp[v + A[i]] = data(v, i);
}
}
//cout << endl;
//break;
}
if (dp.find(X) == end(dp)) {
cout << "No" << endl;
return 0;
}
data cur = dp[X];
while (cur.first >= 0) {
ans[cur.second] = 'o';
cur = dp[cur.first];
}
cout << ans << endl;
}
izryt(趣味)