# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58587 | andy627 | 리조트 (KOI16_resort) | C++17 | 4 ms | 836 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>
#define INF 999999999
using namespace std;
int dp[111][44];
bool cant[111];
int main(){
int n,m;
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++){
int num;
scanf("%d",&num);
cant[num]=1;
}
for(int i=0;i<=n;i++){
for(int j=0;j<=40;j++) dp[i][j]=INF;
}
dp[0][0]=0;
for(int i=0;i<=n;i++){
for(int j=0;j<=40;j++){
dp[i+1][j]=min(dp[i+1][j],dp[i][j]+10);
dp[i+3][j+1]=min(dp[i+3][j+1],dp[i][j]+25);
dp[i+5][j+2]=min(dp[i+5][j+2],dp[i][j]+37);
if(j>=3) dp[i+1][j-3]=min(dp[i+1][j-3],dp[i][j]);
if(cant[i+1]) dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
}
}
int mn=INF;
for(int i=0;i<=40;i++) mn=min(mn,dp[n][i]);
printf("%d",mn*1000);
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... |