結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-07-16 00:34:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 636 ms / 5,000 ms |
| コード長 | 1,146 bytes |
| コンパイル時間 | 601 ms |
| コンパイル使用メモリ | 75,412 KB |
| 実行使用メモリ | 311,208 KB |
| 最終ジャッジ日時 | 2024-12-14 15:30:32 |
| 合計ジャッジ時間 | 4,148 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf("%d%d",&n,&total);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | scanf("%d",&A[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define SIZE 10000
bool dp[51][100001]; //1..* 2..+
string dp_ans[51][100001];
int main(){
int n,total;
int A[SIZE];
string ans;
scanf("%d%d",&n,&total);
for(int i=0;i<n;i++)
scanf("%d",&A[i]);
dp[1][A[0]]=true;
for(int i=1;i<n;i++){
for(int j=0;j<=total;j++){
if(dp[i][j]==false) continue;
if(j*A[i]<=total){
dp_ans[i+1][j*A[i]]=max(dp_ans[i+1][j*A[i]],dp_ans[i][j]+'*');
dp[i+1][j*A[i]]=true;
}
if(j+A[i]<=total){
dp_ans[i+1][j+A[i]]=max(dp_ans[i+1][j+A[i]],dp_ans[i][j]+'+');
dp[i+1][j+A[i]]=true;
}
}
}
cout << dp_ans[n][total] << endl;
return 0;
}
goodbaton