답안 #745317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745317 2023-05-19T20:26:29 Z rainboy Exam (eJOI20_exam) C
0 / 100
6 ms 6420 KB
#include <stdio.h>

#define N	100000
#define N_	5000

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

int main() {
	static int aa[N], bb[N], dp[N_ + 1], ww[N_ + 1][N_ + 1];
	int n, i, j, l, r, k, k_;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &bb[i]);
	if (n <= N_) {
		for (i = 0; i < n; i++) {
			k = 0;
			for (l = i; l >= 0 && (l == i || aa[l] < aa[i]); l--) {
				k_ = k += (bb[l] == aa[i] ? 1 : 0);
				for (r = i; r < n && aa[r] <= aa[i]; r++) {
					if (r > i)
						k_ += (bb[r] == aa[i] ? 1 : 0);
					ww[l][r + 1] = k_;
				}
			}
		}
		dp[0] = 0;
		for (i = 0; i <= n; i++)
			for (j = i + 1; j <= n; j++)
				dp[j] = max(dp[j], dp[i] + ww[i][j]);
		printf("%d\n", dp[n]);
	}
	return 0;
}

Compilation message

exam.c: In function 'main':
exam.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
exam.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
exam.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Incorrect 0 ms 252 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6420 KB Output is correct
2 Incorrect 6 ms 820 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Incorrect 0 ms 252 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Incorrect 0 ms 252 KB Output isn't correct
6 Halted 0 ms 0 KB -