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"
using namespace std;
long long int solve(int N, int K, int *A, int *B) {
int pfB[N]; pfB[0] = B[0];
for (int i = 1; i < N; i++) {
pfB[i] = pfB[i - 1] + B[i];
}
long long res = 0;
for (int i = 0; i < N; i++) {
long long b;
if (i == 0) {
b = pfB[K];
} else {
b = pfB[min((i + K - 1), N - 1)] - pfB[i - 1];
if ((i + K - 1) >= N) b += pfB[(i + K - 1) % N];
}
if (A[i] > b) res += A[i] - b;
}
return res;
}
# | 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... |