답안 #844095

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844095 2023-09-05T08:04:23 Z Acanikolic Exam (eJOI20_exam) C++14
0 / 100
1000 ms 856 KB
#include <bits/stdc++.h>

#define int long long 

using namespace std;

signed main() {
	
	int n;
	cin >> n;
	vector<int>a(n+1),b(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];
	for(int i=1;i<=n;i++) cin >> b[i];
	int res = 0;
	vector<int>dp(n+1,0);
	for(int r=1;r<=n;r++) {
		for(int l=1;l<=r;l++) {
			int mx = 0,pre = 0;
			for(int j=r;j>=1;j--) {
				if(a[j] == b[j]) pre += 1;
				dp[r] = max(dp[r],pre+dp[j-1]);
			}
			for(int j=l;j<=r;j++) mx = max(mx,a[j]);
			int cnt = 0;
			for(int j=l;j<=r;j++) if(b[j] == mx) cnt += 1;
			dp[r] = max(dp[r],dp[l-1]+cnt);
		}
	}
//for(int i=1;i<=n;i++) cout << dp[i] << ' ';
	cout << dp[n];
	return 0;
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:14:6: warning: unused variable 'res' [-Wunused-variable]
   14 |  int res = 0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 627 ms 432 KB Output is correct
2 Execution timed out 1045 ms 856 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 344 KB Output isn't correct
6 Halted 0 ms 0 KB -