# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31741 | somnia0 | 리조트 (KOI16_resort) | C++14 | 0 ms | 1152 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>
int N, M, dynamic[104][104], day[104], price[3]={10000, 25000, 37000}, ans=2000000000;
int main()
{
scanf("%d %d", &N, &M);
for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) dynamic[i][j]=2000000000;
for(int x,i=1;i<=M;i++) scanf("%d", &x), day[x]=1;
dynamic[0][0]=0;
for(int i=1;i<=N+1;i++)
{
for(int coup=0;coup<=N;coup++)
{
if(day[i])
{
dynamic[i][coup]=dynamic[i-1][coup];
continue;
}
for(int p=0;p<3;p++)
for(int v=0;v<=p*2;v++)
if(dynamic[i+v][coup+p]>dynamic[i-1][coup]+price[p]) dynamic[i+v][coup+p]=dynamic[i-1][coup]+price[p];
if(coup>=3&&dynamic[i][coup-3]>dynamic[i-1][coup]) dynamic[i][coup-3]=dynamic[i-1][coup];
}
}
for(int i=0;i<=N;i++) if(ans>dynamic[N][i]) ans=dynamic[N][i];
printf("%d", ans);
}
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... |