#include<stdio.h>
#define MAXDAY 100
int T, N;
int R[MAXDAY + 1];
int D[MAXDAY + 1][MAXDAY * 2 + 1];
void upd(int i, int j, int v) {
if (i > T) return;
if (D[i][j] == -1) D[i][j] = v;
if (D[i][j] > v) D[i][j] = v;
}
int main() {
int i, j, x;
scanf("%d%d", &T, &N);
for (i = 1; i <= T; i++) R[i] = 1;
for (i = 0; i < N; i++) {
scanf("%d", &x);
R[x] = 0;
}
for (i = 0; i <= T; i++) for (j = 0; j <= T * 2; j++) D[i][j] = -1;
D[0][0] = 0;
for (i = 0; i < T; i++) {
for (j = 0; j <= i * 2; j++) {
if (D[i][j] == -1) continue;
if (R[i + 1] == 0) upd(i + 1, j, D[i][j]);
if (j >= 3) upd(i + 1, j - 3, D[i][j]);
upd(i + 1, j, D[i][j] + 10000);
upd(i + 1, j + 1, D[i][j] + 25000);
upd(i + 2, j + 1, D[i][j] + 25000);
upd(i + 3, j + 1, D[i][j] + 25000);
upd(i + 1, j + 2, D[i][j] + 37000);
upd(i + 2, j + 2, D[i][j] + 37000);
upd(i + 3, j + 2, D[i][j] + 37000);
upd(i + 4, j + 2, D[i][j] + 37000);
upd(i + 5, j + 2, D[i][j] + 37000);
}
}
int ans = D[T][0];
for (j = 1; j <= T * 2; j++) ans = (ans > D[T][j]) ? D[T][j] : ans;
printf("%d\n", ans+1);
return 0;
}
Compilation message
resort.cpp: In function 'int main()':
resort.cpp:17:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &T, &N);
^
resort.cpp:20:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &x);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |