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 <string.h>
#define N	100
#define C1	10000
#define C3	25000
#define C5	37000
#define INF	0x3f3f3f3f
int min(int a, int b) { return a < b ? a : b; }
int main() {
	static char banned[N];
	static int dp[N + 1][N + 1];
	int n, m, i, j, c, x, ans;
	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d", &i), i--;
		banned[i] = 1;
	}
	for (i = 0; i <= n; i++)
		memset(dp[i], 0x3f, (n + 1) * sizeof *dp[i]);
	dp[0][0] = 0;
	for (i = 0; i < n; i++)
		for (c = 0; c <= n; c++) {
			x = dp[i][c];
			if (x == INF)
				continue;
			if (banned[i])
				dp[i + 1][c] = min(dp[i + 1][c], x);
			else {
				if (c < 3)
					dp[i + 1][c] = min(dp[i + 1][c], x + C1);
				else
					dp[i + 1][c - 3] = min(dp[i + 1][c - 3], x);
				j = min(i + 3, n);
				dp[j][c + 1] = min(dp[j][c + 1], x + C3);
				j = min(i + 5, n);
				dp[j][c + 2] = min(dp[j][c + 2], x + C5);
			}
		}
	ans = INF;
	for (c = 0; c <= n; c++)
		ans = min(ans, dp[n][c]);
	printf("%d\n", ans);
	return 0;
}
Compilation message (stderr)
resort.c: In function 'main':
resort.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
resort.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d", &i), i--;
      |   ^~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |