Submission #31741

#TimeUsernameProblemLanguageResultExecution timeMemory
31741somnia0리조트 (KOI16_resort)C++14
100 / 100
0 ms1152 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...