답안 #861483

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861483 2023-10-16T10:33:10 Z maks007 Homecoming (BOI18_homecoming) C++14
0 / 100
28 ms 28200 KB
#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(int)> get=[&](int 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(int i = 0; i < n; i ++) a.push_back(A[i]);
	for(int 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";
	for(int i = 0; i < n; i ++) {
		// cout << a[i] - get(i) << " ";
		ans += max(0LL, a[i] - get(i));
	}
	// cout << "\n";
	return ans;
} 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 28200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -