# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61743 | ansol4328 | 리조트 (KOI16_resort) | C++98 | 4 ms | 964 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<algorithm>
using namespace std;
int n, m, d[102];
int dp[102][50];
bool not_going[102];
int main()
{
int out=1e9;
scanf("%d %d",&n,&m);
for(int i=0 ; i<m ; i++)
{
scanf("%d",&d[i]);
not_going[d[i]]=true;
}
for(int i=0 ; i<=n ; i++) for(int j=0 ; j<=45 ; j++) dp[i][j]=1e9;
dp[0][0]=0;
for(int i=1 ; i<=n ; i++)
{
for(int j=0 ; j<=45 ; j++)
{
dp[i][j]=min(dp[i][j],dp[i-1][j]+10000);
if(i>=3 && j>=1) dp[i][j]=min(dp[i][j],dp[i-3][j-1]+25000);
if(i>=5 && j>=2) dp[i][j]=min(dp[i][j],dp[i-5][j-2]+37000);
if(j<=27) dp[i][j]=min(dp[i][j],dp[i-1][j+3]);
if(not_going[i])
{
dp[i][j]=min(dp[i][j],dp[i-1][j]);
}
}
}
for(int i=0 ; i<=45 ; i++) out=min(out,dp[n][i]);
printf("%d",out);
return 0;
}
Compilation message (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... |