Submission #375960

#TimeUsernameProblemLanguageResultExecution timeMemory
375960blackboriExam (eJOI20_exam)C++14
65 / 100
172 ms748 KiB
#include <bits/stdc++.h> using namespace std; int A[5050], B[5050], C[5050], D[5050]; int n, a; int main() { ios::sync_with_stdio(0); cin.tie(0); int i, j, m; cin >> n; for (i = 1; i <= n; i++) { cin >> A[i]; } for (i = 1; i <= n; i++) { cin >> B[i]; } for (i = 1; i <= n; i++) { for (j = i, m = A[i]; j <= n; j++) { if (m <= A[j]) C[j] = 1, m = A[j]; else C[j] = 0; } for (j = i, m = A[i]; j >= 1; j--) { if (m <= A[j]) C[j] = 1, m = A[j]; else C[j] = 0; } for (j = 1, m = 0; j <= n; j++) { m = max(m, D[j]); if (C[j]) D[j] = m + (B[i] == A[j]); else D[j] = 0; a = max(a, D[j]); } } cout << a << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...