답안 #724638

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
724638 2023-04-15T17:03:22 Z vjudge1 Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
1 ms 452 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5+10;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, ans;
vector<ll> arr, tempo;
map<pii, int> dp;

int calc(int i, int at, ll curr, int nxd, int nxu){
	if(i==n) return 0;
	if(dp.find({at, curr})!=dp.end()) return dp[{at, curr}];

	int ret=0;
	if(tempo[nxd]>=curr+abs(arr[at]-arr[nxd])) ret=1+calc(i+1, nxd, curr+abs(arr[at]-arr[nxd]), nxd-1, nxu);
	else ret=calc(i+1, nxd, curr+abs(arr[at]-arr[nxd]), nxd-1, nxu);

	if(tempo[nxu]>=curr+abs(arr[at]-arr[nxu])) ret=max(ret, 1+calc(i+1, nxu, curr+abs(arr[at]-arr[nxu]), nxd, nxu+1));
	else ret=max(ret, calc(i+1, nxu, curr+abs(arr[at]-arr[nxu]), nxd, nxu+1));

	return dp[{at, curr}]=ret;
}

int main(){
  	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    // freopen("shuffle.in","r",stdin);
    // freopen("shuffle.out","w",stdout);

	ll l; cin >> n >> l;

	for(int i=0;i<n;i++){
		ll x; cin >> x;
		arr.pb(x);
	}
	arr.pb(l);
	for(int i=0;i<n;i++) arr.pb(arr[i]+l);

	tempo.resize(2*n+1);
	for(int i=0;i<n;i++) cin >> tempo[i];
	for(int i=0;i<n;i++) tempo[i+n+1]=tempo[i];
	tempo[n]=-1;

	cout << calc(0, n, 0ll, n-1, n+1) << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 452 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -