답안 #1008724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008724 2024-06-26T17:02:49 Z giorgi_pkhaladze Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
460 ms 1048576 KB
#pragma.GCCoptimise("Ofast")
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
using namespace std;
ll n,m,k,i,j,ans,a[205],t[205],d[205][205][25][205];
ll check(int l, int r, int pos, int cnt){
	if(cnt==0)return 1e14;
	if(l>r)return -1e14;
	if(d[l][r][pos][cnt]!=-1)return d[l][r][pos][cnt];
	ll ans=-1e14;
	int lc;
	if(pos==0) lc=l-1;
	else lc=r+1;
	ans=max(ans,check(l+1,r,0,cnt)-(min(abs(a[l]-a[lc]),m-abs(a[l]-a[lc]))));
	ans=max(ans,check(l,r-1,1,cnt)-(min(abs(a[r]-a[lc]),m-abs(a[r]-a[lc]))));
	ans=max(ans,min(t[l],check(l+1,r,0,cnt-1))-(min(abs(a[l]-a[lc]),m-abs(a[l]-a[lc]))));
	ans=max(ans,min(t[r],check(l,r-1,1,cnt-1))-(min(abs(a[r]-a[lc]),m-abs(a[r]-a[lc]))));
	d[l][r][pos][cnt]=ans;
	return ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(k=0; k<n; k++)cin>>a[k];
	for(k=0; k<n; k++)cin>>t[k];
	memset(d,-1,sizeof d);
	ll fans=0;
	for(k=0; k<=n; k++) {
	if(check(0,n-1,1,k)>=0)fans=k;}
	cout<<fans;
}

Compilation message

ho_t3.cpp:1: warning: ignoring '#pragma . GCCoptimise' [-Wunknown-pragmas]
    1 | #pragma.GCCoptimise("Ofast")
      |
# 결과 실행 시간 메모리 Grader output
1 Runtime error 460 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 460 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 460 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 460 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -