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>
#include "homecoming.h"
#include <fstream>
#define endl '\n'
#define mod 998244353
#define INF 9000000000000000000
//#define cin fin
//#define cout fout
//#define fi first
//#define se second
using namespace std;
//ofstream fout("intel.out");
//ifstream fin("intel.in");
long long solve(int N, int K, int *A, int *B) {
long long ans = 0;
long long sol = 0;
bool ok[N] = {};
for(int q = 0; q < N; q++) {
pair<long long,int> best; best.first= -INF;
best.second = -1;
for(int i = 0; i < N; i++) {
long long sum = 0;
if(ok[i] == 1) continue;
for(int j = 0; j < K; j++) {
sum += B[(i+j)%N];
}
if(best.first < A[i]-sum) {
best.first = A[i]-sum;
best.second = i;
}
}
ans += best.first;
ok[best.second] = 1;
for(int j = 0; j < K; j++) {
B[(best.second+j)%N]= 0;
}
sol = max(sol,ans);
}
return sol;
}
# | 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... |