Submission #464303

# Submission time Handle Problem Language Result Execution time Memory
464303 2021-08-12T20:19:55 Z AdamGS Exam (eJOI20_exam) C++14
13 / 100
146 ms 98596 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5007;
int a[LIM], b[LIM], dp[LIM][LIM];
int ma(int l, int r) {
	int ans=0;
	while(l<=r) {
		ans=max(ans, a[l]);
		++l;
	}
	return ans;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	rep(i, n) cin >> a[i+1];
	rep(i, n) cin >> b[i+1];
	rep(i, n) rep(j, n) {
		dp[i+1][j+1]=max(dp[i+1][j], dp[i][j+1]);
		if(a[i+1]==b[j+1] && ma(min(i+1, j+1), max(i+1, j+1))==a[i+1]) {
			dp[i+1][j+1]=max(dp[i+1][j+1], dp[i][j+1])+1;
		}
	}
	cout << dp[n][n] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 8268 KB Output is correct
2 Runtime error 6 ms 716 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 3 ms 3276 KB Output is correct
3 Correct 29 ms 24036 KB Output is correct
4 Correct 129 ms 94384 KB Output is correct
5 Correct 146 ms 98300 KB Output is correct
6 Correct 143 ms 98320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 145 ms 98596 KB Output is correct
2 Runtime error 6 ms 644 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -