結果

問題 No.2549 Paint Eggs
ユーザー tonphytonphy
提出日時 2023-11-25 13:35:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 722 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 69,772 KB
実行使用メモリ 8,240 KB
最終ジャッジ日時 2023-11-25 13:35:18
合計ジャッジ時間 7,076 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,264 KB
testcase_01 AC 3 ms
7,268 KB
testcase_02 AC 3 ms
7,264 KB
testcase_03 AC 3 ms
7,272 KB
testcase_04 AC 4 ms
7,272 KB
testcase_05 AC 3 ms
7,268 KB
testcase_06 AC 3 ms
7,272 KB
testcase_07 AC 4 ms
7,276 KB
testcase_08 AC 3 ms
7,264 KB
testcase_09 AC 3 ms
7,272 KB
testcase_10 AC 114 ms
7,856 KB
testcase_11 AC 106 ms
8,240 KB
testcase_12 AC 85 ms
7,856 KB
testcase_13 AC 108 ms
7,856 KB
testcase_14 AC 78 ms
7,752 KB
testcase_15 AC 10 ms
7,368 KB
testcase_16 AC 100 ms
7,856 KB
testcase_17 AC 69 ms
7,856 KB
testcase_18 AC 59 ms
7,856 KB
testcase_19 AC 81 ms
7,856 KB
testcase_20 AC 141 ms
8,240 KB
testcase_21 AC 139 ms
8,240 KB
testcase_22 AC 139 ms
8,240 KB
testcase_23 AC 140 ms
8,240 KB
testcase_24 AC 141 ms
8,240 KB
testcase_25 AC 138 ms
8,240 KB
testcase_26 AC 139 ms
8,240 KB
testcase_27 AC 139 ms
8,240 KB
testcase_28 AC 141 ms
8,240 KB
testcase_29 AC 139 ms
8,240 KB
testcase_30 AC 139 ms
8,240 KB
testcase_31 AC 138 ms
8,240 KB
testcase_32 AC 139 ms
8,240 KB
testcase_33 AC 139 ms
8,240 KB
testcase_34 AC 138 ms
8,240 KB
testcase_35 AC 139 ms
8,240 KB
testcase_36 AC 139 ms
8,240 KB
testcase_37 AC 142 ms
8,240 KB
testcase_38 AC 138 ms
8,240 KB
testcase_39 AC 141 ms
8,240 KB
testcase_40 AC 140 ms
8,240 KB
testcase_41 AC 141 ms
8,240 KB
testcase_42 AC 139 ms
8,240 KB
testcase_43 AC 139 ms
8,240 KB
testcase_44 AC 138 ms
8,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

typedef long long ll;

int main(){
  ll n,m,k;
  ll color[200005];
  ll cost[200005];
  ll cnt[200005]={0};

  cin>>n>>m>>k;
  for(int i=1;i<=n;i++){
    cin>>color[i];
  }
  for(int i=1;i<=m;i++){
    cin>>cost[i];
  }

  ll minimum=LLONG_MAX;
  for(int i=1;i<=k;i++){
    cnt[color[i]]++;
  }
  for(int i=1;i<=m;i++){
    minimum=min(minimum,cost[i]*(k-cnt[i]));
  }
  for(int i=1;i<=n-k;i++){
    int left=color[i];
    int right=color[i+k];
    cnt[left]--;
    cnt[right]++;
    minimum=min(minimum,cost[left]*(k-cnt[left]));
    minimum=min(minimum,cost[right]*(k-cnt[right]));
  }
  cout<<minimum<<endl;
  return(0);
}
0