이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |