답안 #844086

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844086 2023-09-05T07:49:54 Z Acanikolic Exam (eJOI20_exam) C++14
0 / 100
1000 ms 1116 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);
	for(int r=1;r<=n;r++) {
		for(int l=1;l<=r;l++) {
			int pre = 0;
			for(int j=1;j<l;j++) if(a[j] == b[j]) pre += 1;
			int mx = 0;
			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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 256 ms 428 KB Output is correct
2 Execution timed out 1059 ms 1116 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Halted 0 ms 0 KB -