Submission #536777

#TimeUsernameProblemLanguageResultExecution timeMemory
536777xp875Self Study (JOI22_ho_t2)C++17
62 / 100
1085 ms12608 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { 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]; int c[n]; memset(c, 0, sizeof c); 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 { 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)); if(c[p.second]<m && a[p.second]>b[p.second]) { p.first += a[p.second]; c[p.second]++; } else p.first += b[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...