# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1124301 | hainam2k9 | Collecting Stamps 3 (JOI20_ho_t3) | C++20 | 139 ms | 135316 KiB |
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,l,rs=0;
ll dp[205][205][205][2];
pair<int,int> p[205];
int main()
{
tt;
if(fopen((NAME + ".INP").c_str(), "r")) fo;
cin >> n >> l;
for(int i = 1; i<=n; ++i) cin >> p[i].fi;
for(int i = 1; i<=n; ++i) cin >> p[i].se;
memset(dp,0x3f,sizeof(dp));
dp[0][0][0][0]=dp[0][0][0][1]=0;
p[n+1].fi=l;
for(int k = 1; k<=n; ++k){
for(int i = 0; i<=n; ++i)
for(int j = 0; j<=n-i; ++j){
ll mintime=1e18;
if(i>0) mintime=min({mintime,dp[k-1][i-1][j][0]+p[n-i+2].fi-p[n-i+1].fi,dp[k-1][i-1][j][1]+p[j].fi+l-p[n-i+1].fi});
if(mintime<=p[n-i+1].se) dp[k][i][j][0]=mintime, rs=max(rs,k);
else if(mintime<dp[k-1][i][j][0]) dp[k-1][i][j][0]=mintime;
mintime=1e18;
if(j>0) mintime=min({mintime,dp[k-1][i][j-1][0]+l-p[n-i+1].fi+p[j].fi,dp[k-1][i][j-1][1]+p[j].fi-p[j-1].fi});
if(mintime<=p[j].se) dp[k][i][j][1]=mintime, rs=max(rs,k);
else if(mintime<dp[k-1][i][j][1]) dp[k-1][i][j][1]=mintime;
}
}
cout << rs;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |