結果

問題 No.2549 Paint Eggs
ユーザー FplusFplusFFplusFplusF
提出日時 2023-11-25 14:25:52
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,520 bytes
コンパイル時間 3,142 ms
コンパイル使用メモリ 255,192 KB
実行使用メモリ 14,276 KB
最終ジャッジ日時 2023-11-25 14:26:21
合計ジャッジ時間 27,948 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 2 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 3 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 3 ms
6,676 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
    }
}
struct s{
    __int128 v,k,a;
    
};
bool operator<(s a,s b){
    return a.v<b.v;
}
s op(s a,s b){
    return min(a,b);
}
s e(){
    return {INF,INF,INF};
}
s mapping(ll f,s x){
    s ret=x;
    ret.k+=f;
    ret.v=ret.a*ret.k;
    return ret;
}
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<vector<ll>> v(m);
    vector<ll> c(n);
    rep(i,n){
        cin >> c[i];
        c[i]--;
    }
    vector<ll> a(m);
    rep(i,m) cin >> a[i];
    vector<ll> cnt(m,0);
    rep(i,n) cnt[c[i]]++;
    vector<ll> ord(m);
    rep(i,m) ord[i]=i;
    sort(all(ord),[&](ll i,ll j){
        return cnt[j]<cnt[i];
    });
    ll q=0,ans=INF;
    for(auto &i:ord){
        ll now=0;
        rep(j,k){
            if(c[j]!=i) now+=a[i];
        }
        chmin(ans,now);
        for(ll j=k;j<n;j++){
            if(c[j-k]!=i) now-=a[i];
            if(c[j]!=i) now+=a[i];
            chmin(ans,now);
        }
        q++;
        if(4000<=q) break;
    }
    cout << ans << '\n';
}
0