This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n,m; cin>>n>>m;
vector<ll> a(n), b(n);
for (auto &i: a) cin>>i;
for (int i=0; i<n; i++) {
cin>>b[i];
a[i]=max(a[i],b[i]);
}
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
for (int i=0; i<n; i++) q.push({0ll,i});
vector<int> times(n,0);
for (int i=0; i<n*m; i++) {
auto t=q.top(); q.pop();
if (times[t.second]<m) {
t.first+=a[t.second];
times[t.second]++;
} else {
t.first+=b[t.second];
}
q.push(t);
}
cout<<q.top().first;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |