結果
問題 | No.2549 Paint Eggs |
ユーザー |
|
提出日時 | 2025-03-31 22:55:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 4,158 ms |
コンパイル使用メモリ | 281,700 KB |
実行使用メモリ | 17,408 KB |
最終ジャッジ日時 | 2025-03-31 22:56:21 |
合計ジャッジ時間 | 23,780 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 45 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; void solve(){ ll N,M,K; cin>>N>>M>>K; ll S=0; vector<ll> C(M,0); multiset<ll> MS; for(int i=0;i<M;i++)MS.insert(0); vector<ll> P(N),Q(M); for(ll i=0;i<N;i++){ cin>>P[i]; P[i]--; } for(ll i=0;i<M;i++){ cin>>Q[i]; } for(ll i=0;i<K;i++){ S+=Q[P[i]]; MS.erase(MS.find(C[P[i]])); C[P[i]]+=Q[P[i]]; MS.insert(C[P[i]]); } ll an=S-*(prev(MS.end())); for(int i=0;i<N-K;i++){ S-=Q[P[i]]; S+=Q[P[i+K]]; MS.erase(MS.find(C[P[i]])); C[P[i]]-=Q[P[i]]; MS.insert(C[P[i]]); MS.erase(MS.find(C[P[i+K]])); C[P[i]]+=Q[P[i+K]]; MS.insert(C[P[i+K]]); an=min(an,S-*(prev(MS.end()))); } cout<<an<<endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int T=1; // cin>>T; while(T--)solve(); }