結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-29 18:42:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,545 bytes |
| コンパイル時間 | 908 ms |
| コンパイル使用メモリ | 93,324 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-14 05:10:53 |
| 合計ジャッジ時間 | 1,624 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:53:28: warning: left shift count >= width of type [-Wshift-count-overflow]
53 | vector<ll> dp(T + 1, 1 << 51), sub(T + 1, 1 << 51);
| ~~^~~~~
main.cpp:53:49: warning: left shift count >= width of type [-Wshift-count-overflow]
53 | vector<ll> dp(T + 1, 1 << 51), sub(T + 1, 1 << 51);
| ~~^~~~~
main.cpp:57:29: warning: left shift count >= width of type [-Wshift-count-overflow]
57 | sub.assign(T + 1, 1 << 51);
| ~~^~~~~
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;
using namespace std;
inline int input(){
int a;
cin >> a;
return a;
}
template <typename T>
inline void output(T a, int p) {
if(p){
cout << fixed << setprecision(p) << a << "\n";
}
else{
cout << a << "\n";
}
}
// end of template
int main() {
cin.tie(0);
// source code
int N = input();
int T = input();
vector<int> A(N);
rep(i, N){
cin >> A[i];
}
vector<ll> dp(T + 1, 1 << 51), sub(T + 1, 1 << 51);
dp[0] = 0;
rep(i, N){
sub.assign(T + 1, 1 << 51);
rep(j, T){
if (j + A[i] <= T) {
sub[j + A[i]] = min(sub[j + A[i]], dp[j] * 2);
}
if (j * A[i] <= T) {
sub[j * A[i]] = min(sub[j * A[i]], dp[j] * 2 + 1);
}
}
dp = sub;
}
// output(dp[T], 0);
string ret = "";
for (int i = N - 2; i >= 0; i--) {
if (dp[T] % 2) ret += '*', dp[T] = (dp[T] - 1) / 2;
else ret += '+', dp[T] /= 2;
}
reverse(ret.begin(), ret.end());
output(ret, 0);
return 0;
}