Submission #536769

#TimeUsernameProblemLanguageResultExecution timeMemory
536769xp875Self Study (JOI22_ho_t2)C++17
35 / 100
1078 ms12040 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n, m; cin >> n >> m; ll a[n], b[n]; for(int i=0; i<n; i++) cin >> a[i]; for(int i=0; i<n; i++) cin >> b[i]; if(m==1) { ll ans = (ll)1<<60; for(int i=0; i<n; i++) { ans = min(ans, max(a[i], b[i])); } cout << ans; } else { //a[i] == b[i] set<pair<ll, ll> > s; for(int i=0; i<n; i++) { s.insert(make_pair(0, i)); } for(int i=0; i<m*n; i++) { pair<ll, ll> p = *s.begin(); s.erase(s.find(p)); p.first += a[p.second]; s.insert(p); } //for(auto p : s) cout << p.first << ' '; cout << s.begin()->first; } }
#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...