# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
842151 | konber | Exam (eJOI20_exam) | C++14 | 1 ms | 756 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 <iostream>
#include <vector>
using namespace std;
vector<int> A, b;
int N;
int f(vector<int> a, int i){
if(i==N){
int ans=0;
for(int j=0; j < N; j++) ans += a[j]==b[j];
return ans;
}
int j=i, k=i;
bool changes=true;
vector<int> a1=a, a2=a;
while(changes){
changes = false;
if(j >= 0 && a[j] <= b[i]){
a1[j] = b[i];
changes=true;
j--;
}
if(k <= N-1 && a[k] <= b[i]){
a2[k] = b[i];
changes=true;
k++;
}
if(j==0 && k==N-1) break;
}
return max(f(a, i+1), max(f(a1, i+1), f(a2, i+1)));
}
int main()
{
scanf("%d", &N);
A.resize(N);
b.resize(N);
for(int i=0; i < N; i++)
scanf("%d", &A[i]);
for(int i=0; i < N; i++)
scanf("%d", &b[i]);
if(N <= 10){
cout << f(A, 0) << endl;
}
}
Compilation message (stderr)
# | 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... |