結果

問題 No.10 +か×か
コンテスト
ユーザー togari_takamoto
提出日時 2015-12-13 06:46:04
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,078 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 797 ms
コンパイル使用メモリ 102,444 KB
最終ジャッジ日時 2026-01-07 01:32:00
合計ジャッジ時間 1,403 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:23: エラー: ‘uint64_t’ was not declared in this scope
   31 |         vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
      |                       ^~~~~~~~
main.cpp:18:1: 備考: ‘uint64_t’ is defined in header ‘<cstdint>’; this is probably fixable by adding ‘#include <cstdint>’
   17 | #include <limits>
  +++ |+#include <cstdint>
   18 | using namespace std;
main.cpp:31:23: エラー: template argument 1 is invalid
   31 |         vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
      |                       ^~~~~~~~
main.cpp:31:23: エラー: template argument 2 is invalid
main.cpp:31:31: エラー: template argument 1 is invalid
   31 |         vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
      |                               ^~
main.cpp:31:31: エラー: template argument 2 is invalid
main.cpp:31:61: エラー: template argument 2 is invalid
   31 |         vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
      |                                                             ^
main.cpp:31:98: エラー: expression list treated as compound expression in initializer [-fpermissive]
   31 |         vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
      |                                                                                                  ^
main.cpp:32:11: エラー: invalid types ‘int[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]’ for array subscript
   32 |         dp[a[0]][0] = 0;
      |           ^
main.cpp:34:28: エラー: invalid types ‘int[ll {aka long long int}]’ for array subscript
   34 |                 auto v = dp[j][i];
      |                            ^
main.cpp:35:48: エラー: invalid 

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <iomanip>
#include <numeric>
#include <memory>
#include <limits.h>
#include <set>
#include <cassert>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define TEN(x) ((ll)1e##x)
#define ALL(v) (v).begin(), (v).end()

int main(){
	ll n, total;
	cin >> n >> total;
	vector<ll> a(n);
	for (auto&i : a) cin >> i;
	vector<vector<uint64_t>> dp(total+1, vector<uint64_t>(n, numeric_limits<uint64_t>::max()));
	dp[a[0]][0] = 0;
	REP(i,n-1) REP(j, total + 1) {
		auto v = dp[j][i];
		if (j + a[i + 1] <= total && dp[j + a[i + 1]][i + 1] > v) dp[j + a[i + 1]][i + 1] = v;
		v = bitset<64>(v).set(n-2-i).to_ullong();
		if (j * a[i + 1] <= total && dp[j * a[i + 1]][i + 1] > v) dp[j * a[i + 1]][i + 1] = v;
	}

	auto v = bitset<64>(dp[total][n - 1]);
	for (ll i = n - 2; i >= 0; --i) cout << (v.test(i) ? "*" : "+");
	cout << endl;
	return 0;
}
0