#include "bits/stdc++.h"
#include "homecoming.h"
using namespace std;
#define intl long long
intl solve(int n, int k, int *A, int *B) {
vector <intl> a, b, pref(n, 0);
function <intl(intl)> get=[&](intl idx) {
if(idx + k - 1 < n) return (pref[idx+k-1]-(idx?pref[idx-1]:0LL))*1LL;
else {
intl ans = (pref[n-1]-(idx?pref[idx-1]:0LL)) * 1LL;
ans += (pref[(idx+k-1)%n])*1LL;
return ans;
}
};
for(intl i = 0; i < n; i ++) a.push_back(A[i]);
for(intl i = 0; i < n; i ++) b.push_back(B[i]);
intl ans = 0;
/*for(int i = 0; i < n; i ++) {
if(i) pref[i] = pref[i-1];
pref[i] += (b[i] * 1LL);
}*/
// for(auto i : pref) cout << i << " ";
// cout << "\n";
set <intl> bought;
for(intl step = 0; step < 100; step ++) {
for(intl i = 0; i < n; i ++) {
intl bank = a[i], kk = k;
vector <intl> willbuy;
for(intl j = i; kk >= 1; j ++, kk --) {
j %= n;
if(bought.count(j)) continue;
bank -= b[j];
willbuy.push_back(j);
}
if(bank < 0) continue;
ans += bank;
for(auto j : willbuy) bought.insert(j);
}
}
assert(ans >= 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
24524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |