-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path13302.cpp
More file actions
74 lines (73 loc) · 1.61 KB
/
13302.cpp
File metadata and controls
74 lines (73 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
#define INF 987654321
int t1=10000;
int t2=25000;
int t3=37000;
bool days[101];
int v[101][110];//110
int n,m;
int main()
{
int x;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>x;
days[x]=true;
}
for(int i=0;i<101;i++)
for(int j=0;j<110;j++)
v[i][j]=INF;
v[0][0]=0;
//v[i][j] i 번째 가지 완료 j개 쿠폰가지고 있는 상태
for(int i=1;i<=n;i++)
{
if(days[i]==true){
for(int j=0;j<=109;j++)
{
v[i][j]=min(v[i][j],v[i-1][j]);
}
}
for(int j=0;j<=109;j++)
{
if(i-1>=0){
if(j+3<=108&&v[i-1][j+3]!=INF){
v[i][j]=min(v[i][j],v[i-1][j+3]);
}
v[i][j]=min(v[i-1][j]+t1,v[i][j]);
}
if(i-3>=0){
if(j>=1&&j+1<=109){
if(v[i-3][j-1]!=INF){
v[i][j]=min(v[i][j],v[i-3][j-1]+t2);
}
}
}
if(i-5>=0){
if(j>=2&&j+2<=109){
if(v[i-5][j-2]!=INF){
v[i][j]=min(v[i][j],v[i-5][j-2]+t3);}
}
}
}
}
int ans=INF;
for(int i=0;i<109;i++)
{
ans=min(ans,v[n][i]);
}
cout<<ans<<endl;
// for(int j=0;j<30;j++)
// {
// for(int i=0;i<15;i++)
// printf("%09d ",v[i][j]);
// cout<<endl;
// }
}