Submission #527877

# Submission time Handle Problem Language Result Execution time Memory
527877 2022-02-18T15:14:59 Z rainboy 코알라 (JOI13_koala) C
20 / 100
7 ms 560 KB
#include <stdio.h>

#define N	1000
#define INF	0x3f3f3f3f3f3f3f3fLL

long long max(long long a, long long b) { return a > b ? a : b; }

int main() {
	static int xx[N + 2], bb[N + 2];
	static long long dp[N + 2];
	int n, xl, xr, d, a, i, j;

	scanf("%d%d%d%d%d", &xl, &xr, &d, &a, &n);
	xx[0] = xl;
	for (i = 1; i <= n; i++)
		scanf("%d%d", &xx[i], &bb[i]);
	xx[n + 1] = xr;
	n += 2;
	dp[0] = 0;
	for (j = 1; j < n; j++) {
		dp[j] = -INF;
		for (i = 0; i < j; i++)
			dp[j] = max(dp[j], dp[i] - (long long) (xx[j] - xx[i] + d - 1) / d * a + bb[j]);
	}
	printf("%lld\n", dp[n - 1]);
	return 0;
}

Compilation message

koala.c: In function 'main':
koala.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d%d%d%d", &xl, &xr, &d, &a, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
koala.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d%d", &xx[i], &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 3 ms 288 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 4 ms 296 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
9 Correct 4 ms 292 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 552 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 560 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -