結果

問題 No.2549 Paint Eggs
ユーザー Today03Today03
提出日時 2023-11-25 18:12:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 208,076 KB
実行使用メモリ 11,376 KB
最終ジャッジ日時 2023-11-25 18:12:27
合計ジャッジ時間 10,000 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 134 ms
10,544 KB
testcase_11 AC 132 ms
10,896 KB
testcase_12 AC 102 ms
7,552 KB
testcase_13 AC 129 ms
10,392 KB
testcase_14 AC 91 ms
10,016 KB
testcase_15 AC 9 ms
6,676 KB
testcase_16 AC 118 ms
8,064 KB
testcase_17 AC 83 ms
7,040 KB
testcase_18 AC 70 ms
6,676 KB
testcase_19 AC 97 ms
7,552 KB
testcase_20 AC 170 ms
11,376 KB
testcase_21 AC 168 ms
11,376 KB
testcase_22 AC 192 ms
11,376 KB
testcase_23 AC 169 ms
11,376 KB
testcase_24 AC 173 ms
11,376 KB
testcase_25 AC 162 ms
11,376 KB
testcase_26 AC 162 ms
11,376 KB
testcase_27 AC 163 ms
11,376 KB
testcase_28 AC 171 ms
11,376 KB
testcase_29 AC 174 ms
11,376 KB
testcase_30 AC 171 ms
11,376 KB
testcase_31 AC 166 ms
11,376 KB
testcase_32 AC 168 ms
11,376 KB
testcase_33 AC 176 ms
11,376 KB
testcase_34 AC 165 ms
11,376 KB
testcase_35 AC 171 ms
11,376 KB
testcase_36 AC 169 ms
11,376 KB
testcase_37 AC 168 ms
11,376 KB
testcase_38 AC 170 ms
11,376 KB
testcase_39 AC 174 ms
11,376 KB
testcase_40 AC 171 ms
11,376 KB
testcase_41 AC 171 ms
11,376 KB
testcase_42 AC 176 ms
11,376 KB
testcase_43 AC 171 ms
11,376 KB
testcase_44 AC 170 ms
11,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include("Today's/debug.cpp")
#include "Today's/debug.cpp"
#else
#define debug(...)
#define print_line
#define debugc(...)
#define cerr \
	if (false) cerr
#endif
#include <atcoder/segtree>
using namespace atcoder;

long long op(long long a, long long b) {
	return min(a, b);
}
long long e() {
	return LLONG_MAX;
}

int main() {
	int N, M, K;
	cin >> N >> M >> K;
	vector<int> C(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		C[i]--;
	}
	vector<long long> A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	segtree<long long, op, e> st(M);
	for (int i = 0; i < M; i++) {
		st.set(i, A[i] * K);
	}
	long long ans = LLONG_MAX;
	for (int i = 0; i < K; i++) {
		st.set(C[i], st.get(C[i]) - A[C[i]]);
	}
	for (int i = 0; i + K <= N; i++) {
		ans = min(ans, st.all_prod());
		st.set(C[i], st.get(C[i]) + A[C[i]]);
		if (i + K < N) {
			st.set(C[i + K], st.get(C[i + K]) - A[C[i + K]]);
		}
	}
	cout << ans << endl;
}
0