Submission #920609

# Submission time Handle Problem Language Result Execution time Memory
920609 2024-02-02T18:59:50 Z rainboy None (KOI17_cook) C++17
0 / 100
1 ms 2648 KB
#include <stdio.h>

#define N	3000
#define K	3000
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int ss[N + 1][K], pp[K], dp[N + 1][K], dq[K];
	int n, k, l, r, t, h, h1, h2, h3, h_, i, ans;

	scanf("%d%d%d%d%d", &k, &n, &l, &r, &t);
	for (h = 0; h < k; h++)
		for (i = 1; i <= n; i++)
			scanf("%d", &ss[i][h]);
	for (i = 1; i <= n; i++)
		for (h = 0; h < k; h++)
			ss[i][h] += ss[i - 1][h];
	for (h = 0; h < k; h++)
		scanf("%d", &pp[h]), pp[h]--;
	for (i = 0; i <= n; i++) {
		for (h = 0; h < k; h++)
			dp[i][h] = dq[h] + ss[i][h];
		h1 = h2 = h3 = -1;
		for (h = 0; h < k; h++)
			if (h1 == -1 || dp[i][h1] > dp[i][h])
				h3 = h2, h2 = h1, h1 = h;
			else if (h2 == -1 || dp[i][h2] > dp[i][h])
				h3 = h2, h2 = h;
			else if (h3 == -1 || dp[i][h3] > dp[i][h])
				h3 = h;
		for (h = 0; h < k; h++) {
			if (h1 != h && h1 != pp[h])
				h_ = h1;
			else if (h2 != h && h2 != pp[h])
				h_ = h2;
			else
				h_ = h3;
			dq[h] = min(dq[h], dp[i][h_] - ss[i][h]);
		}
	}
	ans = INF;
	for (h = 0; h < k; h++)
		ans = min(ans, dp[n][h]);
	printf("%d\n", ans);
	return 0;
}

Compilation message

cook.cpp: In function 'int main()':
cook.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d%d%d", &k, &n, &l, &r, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cook.cpp:16:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |    scanf("%d", &ss[i][h]);
      |    ~~~~~^~~~~~~~~~~~~~~~~
cook.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &pp[h]), pp[h]--;
      |   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -