結果

問題 No.2549 Paint Eggs
ユーザー tnakao0123tnakao0123
提出日時 2023-11-25 22:38:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 943 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 52,808 KB
実行使用メモリ 13,272 KB
最終ジャッジ日時 2023-11-25 22:38:15
合計ジャッジ時間 5,779 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,896 KB
testcase_01 AC 4 ms
7,896 KB
testcase_02 AC 4 ms
7,896 KB
testcase_03 AC 4 ms
7,896 KB
testcase_04 AC 4 ms
7,896 KB
testcase_05 AC 4 ms
7,896 KB
testcase_06 AC 4 ms
7,896 KB
testcase_07 AC 4 ms
7,896 KB
testcase_08 AC 4 ms
7,896 KB
testcase_09 AC 4 ms
7,896 KB
testcase_10 AC 70 ms
12,376 KB
testcase_11 AC 56 ms
11,096 KB
testcase_12 AC 56 ms
11,224 KB
testcase_13 AC 67 ms
12,120 KB
testcase_14 AC 42 ms
10,200 KB
testcase_15 AC 7 ms
8,152 KB
testcase_16 AC 64 ms
11,864 KB
testcase_17 AC 70 ms
10,584 KB
testcase_18 AC 38 ms
10,200 KB
testcase_19 AC 49 ms
11,096 KB
testcase_20 AC 83 ms
13,272 KB
testcase_21 AC 87 ms
13,272 KB
testcase_22 AC 85 ms
13,272 KB
testcase_23 AC 86 ms
13,272 KB
testcase_24 AC 89 ms
13,272 KB
testcase_25 AC 89 ms
13,272 KB
testcase_26 AC 87 ms
13,272 KB
testcase_27 AC 84 ms
13,272 KB
testcase_28 AC 94 ms
13,272 KB
testcase_29 AC 88 ms
13,272 KB
testcase_30 AC 91 ms
13,272 KB
testcase_31 AC 88 ms
13,272 KB
testcase_32 AC 91 ms
13,272 KB
testcase_33 AC 89 ms
13,272 KB
testcase_34 AC 90 ms
13,272 KB
testcase_35 AC 89 ms
13,272 KB
testcase_36 AC 88 ms
13,272 KB
testcase_37 AC 91 ms
13,272 KB
testcase_38 AC 92 ms
13,272 KB
testcase_39 AC 89 ms
13,272 KB
testcase_40 AC 88 ms
13,272 KB
testcase_41 AC 92 ms
13,272 KB
testcase_42 AC 85 ms
13,272 KB
testcase_43 AC 88 ms
13,272 KB
testcase_44 AC 89 ms
13,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2549.cc:  No.2549 Paint Eggs - yukicoder
 */

#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 200000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;

/* global variables */

/* subroutines */

int cs[MAX_N], as[MAX_M];
vi cvs[MAX_M];

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%d", cs + i), cs[i]--;
  for (int i = 0; i < m; i++) scanf("%d", as + i);

  for (int i = 0; i < n; i++) cvs[cs[i]].push_back(i);

  ll mins = (ll)k * *min_element(as, as + m);
  for (int ci = 0; ci < m; ci++) {
    vi &cv = cvs[ci];
    int l = cv.size();
    for (int i = 0, j = 0; i < l; i++) {
      while (j < l && cv[j] - cv[i] < k) j++;
      ll s = (ll)(k - (j - i)) * as[ci];
      mins = min(mins, s);
    }
  }

  printf("%lld\n", mins);

  return 0;
}
0