結果
| 問題 |
No.2549 Paint Eggs
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2023-11-25 14:50:31 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 340 ms / 2,000 ms |
| コード長 | 1,499 bytes |
| コンパイル時間 | 2,694 ms |
| コンパイル使用メモリ | 252,672 KB |
| 実行使用メモリ | 14,080 KB |
| 最終ジャッジ日時 | 2024-09-26 10:48:15 |
| 合計ジャッジ時間 | 13,298 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
if(a>b){
a=b;
}
}
template<class T> void chmax(T &a,T b){
if(a<b){
a=b;
}
}
ll op(ll a,ll b){
return min(a,b);
}
ll e(){
return INF;
}
ll mapping(ll f,ll x){
return x+f;
}
ll composition(ll f,ll g){
return f+g;
}
ll id(){
return 0;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n,m,k;
cin >> n >> m >> k;
vector<ll> c(n);
rep(i,n){
cin >> c[i];
c[i]--;
}
vector<ll> a(m);
rep(i,m) cin >> a[i];
atcoder::lazy_segtree<ll,op,e,ll,mapping,composition,id> seg(m);
rep(i,m) seg.set(i,0);
ll ans=INF;
for(ll i=k-1;i<n;i++){
if(i==k-1){
rep(j,k){
seg.apply(0,c[j],1);
seg.apply(c[j]+1,m,1);
}
rep(j,m){
chmin(ans,seg.get(j)*a[j]);
}
}else{
seg.apply(0,c[i-k],-1);
seg.apply(c[i-k]+1,m,-1);
seg.apply(0,c[i],1);
seg.apply(c[i]+1,m,1);
}
chmin(ans,seg.get(c[i])*a[c[i]]);
chmin(ans,seg.get(c[i-k+1])*a[c[i-k+1]]);
}
rep(i,m) chmin(ans,a[i]*n);
cout << ans << '\n';
}
FplusFplusF