Submission #370801

#TimeUsernameProblemLanguageResultExecution timeMemory
370801TraduttoreExam (eJOI20_exam)C++14
0 / 100
3 ms748 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define F first #define S second #define pb push_back #define ld long double #define int ll #define pll pair <ll,ll> #define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0) #define TIME 1.0*clock()/CLOCKS_PER_SEC using namespace std; using namespace __gnu_pbds; mt19937_64 gen(time(0)); int n,q; vector <int> a; vector <int> b; void init() { cin>>n; a.resize(n); for (int i = 0;i < n;i++) cin>>a[i]; b.resize(n); for (int i = 0;i < n;i++) cin>>b[i]; } ll ans = 0; void output() { cout<<ans<<'\n'; } void solve() { bool can = true; for (int i = 0;i < n;i++) if (a[i] == b[0]) { can = false; break; } if (can == true) return; for (int i = 0;i < n;i++) if (a[i] <= b[0]) ++ans; } unordered_map <int,int> mp; void solve2() { for (int i = 0;i < n;i++) ++mp[a[i]]; for (int i = 0;i < n;i++) if (mp[b[i]] && a[i] <= b[i]) { ++ans; } } int32_t main() { srand(time(0)); //freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); IOS; int test; test = 1; while (test--) { init(); bool has = true; for (int i = 0;i < n - 1;i++) if (b[i] != b[i + 1]) { has = false; break; } if (has == true) solve(); else solve2(); output(); } exit(0);} /*3 5 7 9 10 11*/ /*5 14 13 8 14 11*/
#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...