結果
問題 | No.10 +か×か |
ユーザー | hirokazu1020 |
提出日時 | 2015-04-21 23:09:15 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 251 ms / 5,000 ms |
コード長 | 923 bytes |
コンパイル時間 | 532 ms |
コンパイル使用メモリ | 76,092 KB |
実行使用メモリ | 8,508 KB |
最終ジャッジ日時 | 2023-08-21 06:12:09 |
合計ジャッジ時間 | 2,319 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
8,308 KB |
testcase_01 | AC | 5 ms
8,508 KB |
testcase_02 | AC | 4 ms
8,220 KB |
testcase_03 | AC | 251 ms
8,304 KB |
testcase_04 | AC | 151 ms
8,264 KB |
testcase_05 | AC | 150 ms
8,248 KB |
testcase_06 | AC | 238 ms
8,256 KB |
testcase_07 | AC | 155 ms
8,204 KB |
testcase_08 | AC | 48 ms
8,216 KB |
testcase_09 | AC | 33 ms
8,256 KB |
testcase_10 | AC | 8 ms
8,228 KB |
testcase_11 | AC | 7 ms
8,204 KB |
ソースコード
#include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) bool dp[50][100001]; int main(){ int n,total,a[50]; string ans; cin>>n>>total; rep(i,n)cin>>a[i]; int v=a[0]; rep(i,n-1){ memset(dp,false,sizeof(dp)); dp[i+1][v+a[i+1]]=true; for(int j=i+1;j<n-1;j++)rep(k,100001)if(dp[j][k]){ if(k+a[j+1]<=100000)dp[j+1][k+a[j+1]]=true; if(k*a[j+1]<=100000)dp[j+1][k*a[j+1]]=true; } if(dp[n-1][total]){ ans+='+'; v+=a[i+1]; } else{ ans+='*'; v*=a[i+1]; } } cout<<ans<<endl; return 0; }