Submission #1174656

#TimeUsernameProblemLanguageResultExecution timeMemory
1174656nuutsnoyntonKralj (COCI16_kralj)C++20
0 / 140
308 ms16060 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m, r,lo, hi,can, mid, x, y, i, j, ans, t; cin >> n; ll ind[n + 2], b[n + 2], a[n + 2], cnt[n + 2]; for (i = 1; i <= n; i ++) { cnt[i] = 0; } ans = 0; for (i = 1; i <= n; i ++) { cin >> ind[i]; if ( cnt[ind[i]] == 1) ans = 1; cnt[ind[i]] = 1; } for (i = 1; i <= n; i ++) cin >> b[i]; for (i = 1; i <= n; i ++) cin >> a[i]; if ( ans == 1) { ans = 0; for (i = 1; i <= n; i ++) { if ( a[i] > b[ind[i]]) ans ++; } cout << ans << endl; return 0; } sort(a + 1, a + n + 1); sort (b + 1, b + n + 1); lo = 0; hi = n + 1; while ( lo < hi) { mid = (lo + hi)/2; can = 1; for (i = 1; i <= mid; i++) { if ( a[n + 1 - i] < b[mid + 1 - i]) can =0 ; } if ( can == 1) lo =mid + 1; else hi = mid; } cout << lo - 1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...