| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 815959 | vjudge1 | Self Study (JOI22_ho_t2) | C++17 | 54 ms | 6864 KiB |
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>
#define int long long
using namespace std;
void open(){
if(fopen("input.inp", "r")){
freopen("input.inp", "r", stdin);
//freopen("output.out", "w", stdout);
}
}
const int maxn = 3e5 + 5;
int n, m;
int A[maxn], B[maxn];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
open();
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> A[i];
}
for(int i = 1; i <= n; i++){
cin >> B[i];
}
if(m == 1){
int result = 1e9 + 7;
for(int i = 1; i <= n; i++){
result = min(result, max(A[i], B[i]));
}
cout << result << endl;
return 0;
}
if(m * n <= maxn){
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
for(int i = 1; i <= n; i++){
pq.push({0, i});
}
while(m--){
int temp = n;
vector<bool> check(n + 1, false);
while(temp--){
pair<int, int> first = pq.top();
pq.pop();
int old_val = first.first;
int pos = first.second;
if(A[pos] > B[pos] && !check[pos]){
check[pos] = true;
old_val += A[pos];
}else{
old_val += B[pos];
}
pq.push({old_val, pos});
}
}
cout << pq.top().first << endl;
}
return 0;
}
Compilation message (stderr)
| # | 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... | ||||
