# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464305 | AdamGS | Exam (eJOI20_exam) | C++14 | 1098 ms | 98304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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+1][j]+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |