답안 #833212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833212 2023-08-22T03:15:14 Z vjudge1 Exam (eJOI20_exam) C++17
0 / 100
1000 ms 198792 KB
#include<bits/stdc++.h>
using namespace std;

#define For(i, n) for (int i = 0; i < n; i++)

const int MAXN = 5e3;
int N, H[MAXN], T[MAXN], dp[MAXN][MAXN];

int f(int l, int r) {
	if (l > r) return 0;
	if (l == r) {
		if (T[l] == H[l]) return 1;
		return 0;
	}
	if (dp[l][r] != -1) return dp[l][r];
	int terbesar = 0, cnt = 0;
	for (int i = l; i <= r; i++) terbesar = max(terbesar, H[i]);
	for (int i = l; i <= r; i++) {
		if (T[i] == terbesar) {
			cnt++;
		}
	}
	int ans = cnt;
	for (int i = l; i <= r - 1; i++) {
		ans = max(ans, f(l, i) + f(i + 1, r));
	}
	return dp[l][r] = ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	memset(dp, -1, sizeof dp);
	cin >> N;
	For (i, N) cin >> H[i];
	For (i, N) cin >> T[i];
	cout << f(0, N - 1) << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 98124 KB Output is correct
2 Correct 32 ms 98068 KB Output is correct
3 Correct 32 ms 98092 KB Output is correct
4 Correct 33 ms 98116 KB Output is correct
5 Incorrect 32 ms 98068 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 98160 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 98172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 137 ms 198792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 98124 KB Output is correct
2 Correct 32 ms 98068 KB Output is correct
3 Correct 32 ms 98092 KB Output is correct
4 Correct 33 ms 98116 KB Output is correct
5 Incorrect 32 ms 98068 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 98124 KB Output is correct
2 Correct 32 ms 98068 KB Output is correct
3 Correct 32 ms 98092 KB Output is correct
4 Correct 33 ms 98116 KB Output is correct
5 Incorrect 32 ms 98068 KB Output isn't correct
6 Halted 0 ms 0 KB -