結果

問題 No.2549 Paint Eggs
ユーザー FplusFplusFFplusFplusF
提出日時 2023-11-25 14:50:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 402 ms / 2,000 ms
コード長 1,499 bytes
コンパイル時間 3,389 ms
コンパイル使用メモリ 252,948 KB
実行使用メモリ 14,112 KB
最終ジャッジ日時 2023-11-25 14:50:47
合計ジャッジ時間 15,663 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
6,676 KB
testcase_05 AC 3 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 3 ms
6,676 KB
testcase_10 AC 230 ms
13,168 KB
testcase_11 AC 201 ms
13,136 KB
testcase_12 AC 224 ms
9,088 KB
testcase_13 AC 230 ms
12,904 KB
testcase_14 AC 120 ms
12,192 KB
testcase_15 AC 17 ms
6,676 KB
testcase_16 AC 191 ms
9,600 KB
testcase_17 AC 179 ms
8,576 KB
testcase_18 AC 116 ms
6,676 KB
testcase_19 AC 184 ms
8,960 KB
testcase_20 AC 327 ms
14,112 KB
testcase_21 AC 333 ms
14,112 KB
testcase_22 AC 377 ms
14,112 KB
testcase_23 AC 361 ms
14,112 KB
testcase_24 AC 402 ms
14,112 KB
testcase_25 AC 238 ms
14,112 KB
testcase_26 AC 240 ms
14,112 KB
testcase_27 AC 270 ms
14,112 KB
testcase_28 AC 379 ms
14,112 KB
testcase_29 AC 314 ms
14,112 KB
testcase_30 AC 384 ms
14,112 KB
testcase_31 AC 290 ms
14,112 KB
testcase_32 AC 326 ms
14,112 KB
testcase_33 AC 302 ms
14,112 KB
testcase_34 AC 267 ms
14,112 KB
testcase_35 AC 385 ms
14,112 KB
testcase_36 AC 359 ms
14,112 KB
testcase_37 AC 321 ms
14,112 KB
testcase_38 AC 280 ms
14,112 KB
testcase_39 AC 312 ms
14,112 KB
testcase_40 AC 388 ms
14,112 KB
testcase_41 AC 388 ms
14,112 KB
testcase_42 AC 387 ms
14,112 KB
testcase_43 AC 391 ms
14,112 KB
testcase_44 AC 387 ms
14,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0