제출 #462373

#제출 시각아이디문제언어결과실행 시간메모리
462373bigoExam (eJOI20_exam)C++14
0 / 100
9 ms332 KiB
#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 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...