| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 31196 | leejseo | 리조트 (KOI16_resort) | C++98 | 0 ms | 1196 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>
using namespace std;
#define MAX_N 100 // O(N^3)에 돌리면 충분
#define max_coupon(day) ((day)*2)
#define MAX_C max_coupon(MAX_N)
#define MAX_INT 0x7fffffff
int n, m;
int D[MAX_N + 1][MAX_C + 1];
bool skip[MAX_N + 1];
int solve(){
  for (int i = 0; i <= n; i++){
    for(int j=0; j<= 2*i; j++){
      D[i][j] = MAX_INT;
    }
  }
  D[0][0] = 0;
  
  for (int i=0; i<n; i++){
    for (int j=0; j<= 2*i; j++){
      if (D[i][j] == MAX_INT) continue;
      if (skip[i+1]){
        D[i+1][j] = min(D[i+1][j], D[i][j]);
        continue;
      }
      D[i+1][j] = min(D[i+1][j], D[i][j]+10000);
      for (int k=1; k <4; k++){
        if(i+k > n) break;
        D[i+k][j+1] = min(D[i+k][j+1], D[i][j]+25000);
      }
      for (int k=1; k <6; k++){
        if (i+k > n) break;
        D[i+k][j+2] = min(D[i+k][j+2], D[i][j]+37000);
      }
      if (j >= 3) D[i+1][j-3] = min(D[i+1][j-3], D[i][j]);
    }
  }
  int cnt = MAX_INT;
  for (int j=0; j <= 2*n; j++){
    if (cnt > D[n][j]) cnt = D[n][j];
  }
  return cnt;
}
int main(){
  scanf("%d%d", &n, &m);
  for(int i=0; i <= n; i++) skip[i] = false;
  if (m==0){
    int c = solve();
    printf("%d", c);
    return 0;
  }
  for(int i=0; i <= m; i++){
    int ind;
    scanf("%d", &ind);
    skip[ind] = true;
  }
  int c = solve();
  printf("%d", c);
  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... | ||||
