Submission #31741

# Submission time Handle Problem Language Result Execution time Memory
31741 2017-09-03T11:37:03 Z somnia0 None (KOI16_resort) C++14
100 / 100
0 ms 1152 KB
#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

resort.cpp: In function 'int main()':
resort.cpp:5:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &M);
                        ^
resort.cpp:7:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int x,i=1;i<=M;i++) scanf("%d", &x), day[x]=1;
                                                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1152 KB Output is correct
2 Correct 0 ms 1152 KB Output is correct
3 Correct 0 ms 1152 KB Output is correct
4 Correct 0 ms 1152 KB Output is correct
5 Correct 0 ms 1152 KB Output is correct
6 Correct 0 ms 1152 KB Output is correct
7 Correct 0 ms 1152 KB Output is correct
8 Correct 0 ms 1152 KB Output is correct
9 Correct 0 ms 1152 KB Output is correct
10 Correct 0 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1152 KB Output is correct
2 Correct 0 ms 1152 KB Output is correct
3 Correct 0 ms 1152 KB Output is correct
4 Correct 0 ms 1152 KB Output is correct
5 Correct 0 ms 1152 KB Output is correct
6 Correct 0 ms 1152 KB Output is correct
7 Correct 0 ms 1152 KB Output is correct
8 Correct 0 ms 1152 KB Output is correct
9 Correct 0 ms 1152 KB Output is correct
10 Correct 0 ms 1152 KB Output is correct
11 Correct 0 ms 1152 KB Output is correct
12 Correct 0 ms 1152 KB Output is correct
13 Correct 0 ms 1152 KB Output is correct
14 Correct 0 ms 1152 KB Output is correct
15 Correct 0 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1152 KB Output is correct
2 Correct 0 ms 1152 KB Output is correct
3 Correct 0 ms 1152 KB Output is correct
4 Correct 0 ms 1152 KB Output is correct
5 Correct 0 ms 1152 KB Output is correct
6 Correct 0 ms 1152 KB Output is correct
7 Correct 0 ms 1152 KB Output is correct
8 Correct 0 ms 1152 KB Output is correct
9 Correct 0 ms 1152 KB Output is correct
10 Correct 0 ms 1152 KB Output is correct
11 Correct 0 ms 1152 KB Output is correct
12 Correct 0 ms 1152 KB Output is correct
13 Correct 0 ms 1152 KB Output is correct
14 Correct 0 ms 1152 KB Output is correct
15 Correct 0 ms 1152 KB Output is correct
16 Correct 0 ms 1152 KB Output is correct
17 Correct 0 ms 1152 KB Output is correct
18 Correct 0 ms 1152 KB Output is correct
19 Correct 0 ms 1152 KB Output is correct
20 Correct 0 ms 1152 KB Output is correct
21 Correct 0 ms 1152 KB Output is correct
22 Correct 0 ms 1152 KB Output is correct
23 Correct 0 ms 1152 KB Output is correct
24 Correct 0 ms 1152 KB Output is correct
25 Correct 0 ms 1152 KB Output is correct
26 Correct 0 ms 1152 KB Output is correct
27 Correct 0 ms 1152 KB Output is correct
28 Correct 0 ms 1152 KB Output is correct
29 Correct 0 ms 1152 KB Output is correct
30 Correct 0 ms 1152 KB Output is correct
31 Correct 0 ms 1152 KB Output is correct
32 Correct 0 ms 1152 KB Output is correct
33 Correct 0 ms 1152 KB Output is correct
34 Correct 0 ms 1152 KB Output is correct
35 Correct 0 ms 1152 KB Output is correct
36 Correct 0 ms 1152 KB Output is correct
37 Correct 0 ms 1152 KB Output is correct
38 Correct 0 ms 1152 KB Output is correct
39 Correct 0 ms 1152 KB Output is correct
40 Correct 0 ms 1152 KB Output is correct
41 Correct 0 ms 1152 KB Output is correct
42 Correct 0 ms 1152 KB Output is correct
43 Correct 0 ms 1152 KB Output is correct
44 Correct 0 ms 1152 KB Output is correct