이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define FF first.first
#define FS first.second
#define pb push_back
using namespace std;
const ll N=1000006, INF=1e13, P=998244353;
int n, ANS;
ll L;
ll dp[205][205][205][2];
void solve(){
cin>>n>>L;
vector<ll> a(n), T(n);
for (auto &x:a)cin>>x;
for (auto &x:T)cin>>x;
for (int i=0; i<=n; i++)
for (int j=0; j<=n; j++)
for (int k=0; k<=n; k++)
dp[i][j][k][0]=dp[i][j][k][1]=INF;
dp[n][0][0][0]=dp[n][0][0][1]=0;
for (int l=n; l>=0; l--){
for (int r=0; r<=l; r++){
// cout<<r<<" "<<l<<" "<<r+(n-l)<<endl;
for (int ans=0; ans<=n; ans++){
for (int i=0; i<2; i++){
ll curl=(l==n?L:a[l]);
ll curr=(r==0?0:a[r-1]);
ll t=dp[l][r][ans][i];
ll len=curr+(L-curl);
if(t>=INF)continue;
if(l>0 && r<n){
{
ll tt=t+(curl-a[l-1])+((ll)(i^0)*len);
int Ans=ans+(tt<=T[l-1]);
ll &next=dp[l-1][r][Ans][0];
next=min(tt, next);
ANS=max(Ans, ANS);
}
{
ll tt=t+(a[r]-curr)+((ll)(i^1)*len);
int Ans=ans+(tt<=T[r+0]);
ll &next=dp[l][r+1][Ans][1];
next=min(tt, next);
ANS=max(Ans, ANS);
}
}
}
}
}
}
cout<<ANS;
}
main(){ios_base::sync_with_stdio(false), cin.tie(0);
int T=1;
//cin>>T;
while(T--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
ho_t3.cpp:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
64 | main(){ios_base::sync_with_stdio(false), cin.tie(0);
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |