Submission #646487

#TimeUsernameProblemLanguageResultExecution timeMemory
646487AlenygamHomecoming (BOI18_homecoming)C++14
0 / 100
28 ms15620 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...