結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-01 10:53:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,164 ms / 5,000 ms |
| コード長 | 870 bytes |
| コンパイル時間 | 662 ms |
| コンパイル使用メモリ | 73,684 KB |
| 実行使用メモリ | 30,544 KB |
| 最終ジャッジ日時 | 2024-12-14 15:41:15 |
| 合計ジャッジ時間 | 4,023 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main(){
int i, j;
int in[50], total, n;
vector <string> bf(100001);
vector <string> af(100001);
cin >> n;
cin >> total;
for(i = 0; i < n; i++) cin >> in[i];
bf[in[0] * in[1]] = "*";
bf[in[0] + in[1]] = "+";
for(i = 2; i < n; i++){
for(j = 0; j <=total; j++){
if(bf[j].length()>0){
if(j * in[i] <= total){
if ((bf[j] + "*") > af[j* in[i]]) af[j* in[i]] = bf[j] + "*";
}
if(j + in[i] <= total){
if ((bf[j] + "+") > af[j+ in[i]]) af[j+ in[i]] = bf[j] + "+";
}
}
}
for(j = 0; j <=total; j++){
bf[j] = af[j];
af[j] = "";
}
}
cout << bf[total] << endl;
return 0;
}