답안 #203337

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203337 2020-02-20T09:07:28 Z staniewzki Collecting Stamps 3 (JOI20_ho_t3) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)

template<class T> auto create(T x) { return x; }
template<class... Ts> auto create(int n, Ts... x) {
	return vector(n, create(x...));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, len;
	cin >> n >> len;
	vector<int> x(n), t(n);
	REP(i, n) cin >> x[i];
	REP(i, n) cin >> t[i];

	auto dp = create(n + 1, n + 1, n + 1, 2, (long long) 1e9 + 1);

	vector<int> d(n + 2);
	REP(i, n) d[i + 1] = x[i];
	d[n + 1] = len;

	auto left = [&](int a, int b) { return d[b] - d[a]; };
	auto right = [&](int a, int b) { return d[n + 1 - a] - d[n + 1 - b]; };

	dp[0][0][0][0] = 0;
	dp[0][0][0][1] = 0;
	int ans = 0;

	REP(l, n + 1) REP(r, n + 1) {
		if(l + r > n) break;
		REP(k, n + 1) {
			if(l) {
				dp[l][r][k][0] = min(dp[l][r][k][0], dp[l - 1][r][k][0] + left(l - 1, l));
				dp[l][r][k][0] = min(dp[l][r][k][0], dp[l - 1][r][k][1] + left(0, l) + right(0, r));
			}
			if(r) {
				dp[l][r][k][1] = min(dp[l][r][k][1], dp[l][r - 1][k][1] + right(r - 1, r));
				dp[l][r][k][1] = min(dp[l][r][k][1], dp[l][r - 1][k][0] + left(0, l) + right(0, r));
			}
		}

		for(int k = n; k >= 1; k--) {
			if(l && dp[l][r][k - 1][0] <= t[l - 1]) {
				dp[l][r][k][0] = dp[l][r][k - 1][0];
				ans = max(ans, k);
			}
			if(r && dp[l][r][k - 1][1] <= t[n - r]) {
				dp[l][r][k][1] = dp[l][r][k - 1][1];
				ans = max(ans, k);
			}
		}
	}

	cout << ans << "\n";
}

Compilation message

ho_t3.cpp: In function 'auto create(int, Ts ...)':
ho_t3.cpp:8:15: error: missing template arguments before '(' token
  return vector(n, create(x...));
               ^
ho_t3.cpp: In function 'int main()':
ho_t3.cpp:21:7: error: 'void dp' has incomplete type
  auto dp = create(n + 1, n + 1, n + 1, 2, (long long) 1e9 + 1);
       ^~