結果

問題 No.2549 Paint Eggs
ユーザー 👑 kmjpkmjp
提出日時 2023-11-27 21:44:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 730 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 2,619 ms
コンパイル使用メモリ 207,152 KB
実行使用メモリ 17,624 KB
最終ジャッジ日時 2023-11-27 21:45:19
合計ジャッジ時間 20,477 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,640 KB
testcase_01 AC 3 ms
7,640 KB
testcase_02 AC 3 ms
7,640 KB
testcase_03 AC 3 ms
7,640 KB
testcase_04 AC 3 ms
7,640 KB
testcase_05 AC 4 ms
7,640 KB
testcase_06 AC 4 ms
7,640 KB
testcase_07 AC 3 ms
7,640 KB
testcase_08 AC 3 ms
7,640 KB
testcase_09 AC 4 ms
7,640 KB
testcase_10 AC 354 ms
15,192 KB
testcase_11 AC 334 ms
17,496 KB
testcase_12 AC 267 ms
12,632 KB
testcase_13 AC 323 ms
14,936 KB
testcase_14 AC 184 ms
15,064 KB
testcase_15 AC 13 ms
8,024 KB
testcase_16 AC 281 ms
14,296 KB
testcase_17 AC 183 ms
11,352 KB
testcase_18 AC 116 ms
10,840 KB
testcase_19 AC 228 ms
13,016 KB
testcase_20 AC 552 ms
17,624 KB
testcase_21 AC 516 ms
17,624 KB
testcase_22 AC 597 ms
17,624 KB
testcase_23 AC 562 ms
17,624 KB
testcase_24 AC 730 ms
17,624 KB
testcase_25 AC 400 ms
17,624 KB
testcase_26 AC 389 ms
17,624 KB
testcase_27 AC 451 ms
17,624 KB
testcase_28 AC 603 ms
17,624 KB
testcase_29 AC 494 ms
17,624 KB
testcase_30 AC 596 ms
17,624 KB
testcase_31 AC 499 ms
17,624 KB
testcase_32 AC 519 ms
17,624 KB
testcase_33 AC 509 ms
17,624 KB
testcase_34 AC 424 ms
17,624 KB
testcase_35 AC 641 ms
17,624 KB
testcase_36 AC 560 ms
17,624 KB
testcase_37 AC 496 ms
17,624 KB
testcase_38 AC 444 ms
17,624 KB
testcase_39 AC 518 ms
17,624 KB
testcase_40 AC 566 ms
17,624 KB
testcase_41 AC 581 ms
17,624 KB
testcase_42 AC 621 ms
17,624 KB
testcase_43 AC 595 ms
17,624 KB
testcase_44 AC 582 ms
17,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M,K;
ll C[202020];
ll A[202020];
ll cnt[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(i,N) {
		cin>>C[i];
		C[i]--;
	}
	FOR(i,M) cin>>A[i];
	ll mi=1LL<<60;
	multiset<ll> cand;
	FOR(i,M) {
		cnt[i]=K;
		cand.insert(1LL*K*A[i]);
	}
	FOR(i,N) {
		x=C[i];
		cand.erase(cand.find(cnt[x]*A[x]));
		cnt[x]--;
		cand.insert(cnt[x]*A[x]);
		
		if(i>=K) {
			x=C[i-K];
			cand.erase(cand.find(cnt[x]*A[x]));
			cnt[x]++;
			cand.insert(cnt[x]*A[x]);
		}
		if(i>=K-1) mi=min(mi,*cand.begin());
		
		
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0