Submission #504238

#TimeUsernameProblemLanguageResultExecution timeMemory
504238erkePreokret (COCI18_preokret)C++11
50 / 50
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<int> cnt_a(2881), cnt_b(2881); for (int i = 0; i < n; i++) { int x; cin >> x; cnt_a[x]++; } int m; cin >> m; for (int i = 0; i < m; i++) { int x; cin >> x; cnt_b[x]++; } int res2 = 0; vector<int> lost_a(2881), lost_b(2881); for (int i = 1; i <= 2880; i++) { cnt_a[i] += cnt_a[i - 1]; cnt_b[i] += cnt_b[i - 1]; if (cnt_a[i] == cnt_b[i]) { lost_a[i] = lost_a[i - 1]; lost_b[i] = lost_b[i - 1]; } else { lost_a[i] = (cnt_a[i] < cnt_b[i]); lost_b[i] = (cnt_b[i] < cnt_a[i]); } if (lost_a[i - 1] && cnt_a[i] > cnt_b[i]) res2++; if (lost_b[i - 1] && cnt_b[i] > cnt_a[i]) res2++; } int res1 = cnt_a[1440] + cnt_b[1440]; cout << res1 << '\n' << res2 << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...