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"
#define int long long
using namespace std;
const int sz = 15;
int a[sz], b[sz];
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> a[i];
for (int i = 1; i <= n; i ++)
cin >> b[i];
int an = 0;
for (int i = 0; i < (1 << n); i ++) {
int k = 0;
int c = 0;
for (int j = 0; j < n; j = k) {
int tm = 0 < (i & (1 << j));
int mx = 0;
for (; k < n; k ++) {
int r = 0 < (i & (1 << k));
if (r != tm) break;
mx = max(mx, a[k+1]);
}
for (int l = j; l < k; l ++)
if (b[l+1] == mx) c ++;
}
an = max(an, c);
}
cout << an << '\n';
}
# | 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... |