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;
#define ll long long
typedef pair<int, int> pii;
int main() {
int n;
cin >> n;
vector<int>a(n), b(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> b[i];
}
vector<int>ok(n, 0);
for (int i = 0; i < n; i++) {
if (a[i] > b[i])
ok[i] = 2;
else if (a[i] == b[i])
ok[i] = 1;
}
for (int i = 0; i < n; i++) {
if (ok[i]==0) {
int pla = -1;
for (int j = i + 1; j < n; j++) {
if (a[j] == b[i]) {
pla = j;
break;
}
}
if (pla == -1)
ok[i] = 2;
else {
int tmp = 0;
int tmp1 = 1;
for (int j = i + 1; j <= pla; j++) {
if (ok[j] == 1) {
if (b[i] != b[j])
tmp++;
}
if (b[i] == b[j])
tmp1++;
}
if (tmp1 > tmp) {
ok[i] = 1;
for (int j = i + 1; j <= pla; j++) {
if (ok[j] == 1) {
if (b[i] != b[j])
ok[i] = 2;
}
if (b[i] == b[j])
ok[j] = 1;
}
}
}
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (ok[i] == 1)
ans++;
}
cout << ans;
}
| # | 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... |