Submission #923076

# Submission time Handle Problem Language Result Execution time Memory
923076 2024-02-06T14:28:00 Z tvladm2009 Collecting Stamps 3 (JOI20_ho_t3) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "inpu ct";

int n, l;
int x[MAXN], t[MAXN];

int dist(int i, int j) {
	return min(abs(x[i] - x[j]), l - abs(x[i] - x[j]));
}

ll solve(int l, int r, int side, int cnt) {
	if (cnt == 0) {
		return (1LL << 60);
	}
	if (l > r) {
		return -(1LL << 60);
	}
	if (dp[l][r][side][cnt] != -1) {
		return dp[l][r][side][cnt];
	}
	int pos;
	if (side == 0) {
		pos = l - 1;
	} else {
		pos = r + 1;
	}
	ll ans = (1LL << 60);
	chkmax(ans, solve(l + 1, r, 0, cnt) - dist(l, pos));
	chkmax(ans, min(t[l], solve(l + 1, r, 0, cnt)) - dist(l, pos));
	chkmax(ans, solve(l, r - 1, 1, cnt) - dist(r, pos));
	chkmax(ans, min(t[r], solve(l, r - 1, 1, cnt)) - dist(r, pos));
	dp[l][r][side][cnt] = ans;
	return dp[l][r][side][cnt];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read(FILENAME);
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	memset(dp, -1, sizeof(dp));
	ll sol = 0;
	for (int i = 0; i <= n; i++) {
		if (solve(0, n - 1, 1, i) >= 0) {
			sol = i;
		}
	}
	cout << sol << '\n';
	return 0;
}

Compilation message

ho_t3.cpp:44:7: error: 'MAXN' was not declared in this scope
   44 | int x[MAXN], t[MAXN];
      |       ^~~~
ho_t3.cpp:44:16: error: 'MAXN' was not declared in this scope
   44 | int x[MAXN], t[MAXN];
      |                ^~~~
ho_t3.cpp: In function 'int dist(int, int)':
ho_t3.cpp:47:17: error: 'x' was not declared in this scope
   47 |  return min(abs(x[i] - x[j]), l - abs(x[i] - x[j]));
      |                 ^
ho_t3.cpp: In function 'll solve(int, int, int, int)':
ho_t3.cpp:57:6: error: 'dp' was not declared in this scope; did you mean 'mp'?
   57 |  if (dp[l][r][side][cnt] != -1) {
      |      ^~
      |      mp
ho_t3.cpp:68:18: error: 't' was not declared in this scope
   68 |  chkmax(ans, min(t[l], solve(l + 1, r, 0, cnt)) - dist(l, pos));
      |                  ^
ho_t3.cpp:71:2: error: 'dp' was not declared in this scope; did you mean 'mp'?
   71 |  dp[l][r][side][cnt] = ans;
      |  ^~
      |  mp
ho_t3.cpp: In function 'int main()':
ho_t3.cpp:82:10: error: 'x' was not declared in this scope
   82 |   cin >> x[i];
      |          ^
ho_t3.cpp:85:10: error: 't' was not declared in this scope
   85 |   cin >> t[i];
      |          ^
ho_t3.cpp:87:9: error: 'dp' was not declared in this scope; did you mean 'mp'?
   87 |  memset(dp, -1, sizeof(dp));
      |         ^~
      |         mp