結果

問題 No.2549 Paint Eggs
ユーザー binapbinap
提出日時 2023-11-27 06:51:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 1,728 bytes
コンパイル時間 4,679 ms
コンパイル使用メモリ 265,260 KB
実行使用メモリ 11,504 KB
最終ジャッジ日時 2023-11-27 06:52:07
合計ジャッジ時間 11,683 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 130 ms
10,672 KB
testcase_11 AC 118 ms
11,024 KB
testcase_12 AC 100 ms
7,680 KB
testcase_13 AC 123 ms
10,520 KB
testcase_14 AC 87 ms
10,144 KB
testcase_15 AC 9 ms
6,676 KB
testcase_16 AC 114 ms
8,192 KB
testcase_17 AC 80 ms
7,168 KB
testcase_18 AC 67 ms
6,676 KB
testcase_19 AC 94 ms
7,680 KB
testcase_20 AC 162 ms
11,504 KB
testcase_21 AC 161 ms
11,504 KB
testcase_22 AC 163 ms
11,504 KB
testcase_23 AC 162 ms
11,504 KB
testcase_24 AC 190 ms
11,504 KB
testcase_25 AC 156 ms
11,504 KB
testcase_26 AC 157 ms
11,504 KB
testcase_27 AC 158 ms
11,504 KB
testcase_28 AC 165 ms
11,504 KB
testcase_29 AC 161 ms
11,504 KB
testcase_30 AC 165 ms
11,504 KB
testcase_31 AC 159 ms
11,504 KB
testcase_32 AC 164 ms
11,504 KB
testcase_33 AC 159 ms
11,504 KB
testcase_34 AC 157 ms
11,504 KB
testcase_35 AC 188 ms
11,504 KB
testcase_36 AC 162 ms
11,504 KB
testcase_37 AC 161 ms
11,504 KB
testcase_38 AC 159 ms
11,504 KB
testcase_39 AC 160 ms
11,504 KB
testcase_40 AC 162 ms
11,504 KB
testcase_41 AC 162 ms
11,504 KB
testcase_42 AC 163 ms
11,504 KB
testcase_43 AC 164 ms
11,504 KB
testcase_44 AC 164 ms
11,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef long double ld;
typedef pair<int, int> P;

ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;}
template <int m> ostream& operator<<(ostream& os, const static_modint<m>& a) {os << a.val(); return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;}
template<typename U, typename T> ostream& operator<<(ostream& os, const pair<U, T>& p){os << p.first << ' ' << p.second; return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;}
template <typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;}

const long long INF = 1001001001001001001;
using S = long long;
S op(S a, S b){return min(a, b);}
S e(){return INF;}

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	vi c(n);
	vl a(m);
	cin >> c >> a;
	rep(i, n) c[i]--;
	vl init(m);
	rep(i, m) init[i] += a[i] * k;
	segtree<S, op, e> seg(init);
	auto add = [&](int col, int coef = 1){
		auto res = seg.get(col);
		res -= a[col] * coef;
		seg.set(col, res);
	};
	auto del = [&](int col){
		add(col, -1);
	};
	rep(i, k) add(c[i]);
	long long ans = seg.all_prod();
	rep(i, n - k){
		add(c[i + k]);
		del(c[i]);
		ans = min(ans, seg.all_prod());
	}
	cout << ans << "\n";
	return 0;
}
0