結果
問題 | No.2549 Paint Eggs |
ユーザー | tenten |
提出日時 | 2023-11-27 10:42:16 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 506 ms / 2,000 ms |
コード長 | 2,308 bytes |
コンパイル時間 | 2,764 ms |
コンパイル使用メモリ | 88,784 KB |
実行使用メモリ | 60,088 KB |
最終ジャッジ日時 | 2024-09-26 12:13:03 |
合計ジャッジ時間 | 19,426 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
37,704 KB |
testcase_01 | AC | 71 ms
37,404 KB |
testcase_02 | AC | 74 ms
37,596 KB |
testcase_03 | AC | 80 ms
38,172 KB |
testcase_04 | AC | 72 ms
38,028 KB |
testcase_05 | AC | 71 ms
37,536 KB |
testcase_06 | AC | 71 ms
38,040 KB |
testcase_07 | AC | 80 ms
37,456 KB |
testcase_08 | AC | 57 ms
36,912 KB |
testcase_09 | AC | 84 ms
37,816 KB |
testcase_10 | AC | 338 ms
54,976 KB |
testcase_11 | AC | 349 ms
55,800 KB |
testcase_12 | AC | 307 ms
49,704 KB |
testcase_13 | AC | 324 ms
55,496 KB |
testcase_14 | AC | 294 ms
53,048 KB |
testcase_15 | AC | 130 ms
40,580 KB |
testcase_16 | AC | 327 ms
52,560 KB |
testcase_17 | AC | 291 ms
47,644 KB |
testcase_18 | AC | 267 ms
47,244 KB |
testcase_19 | AC | 301 ms
49,372 KB |
testcase_20 | AC | 363 ms
58,832 KB |
testcase_21 | AC | 506 ms
60,088 KB |
testcase_22 | AC | 407 ms
59,892 KB |
testcase_23 | AC | 363 ms
59,100 KB |
testcase_24 | AC | 425 ms
58,696 KB |
testcase_25 | AC | 365 ms
59,388 KB |
testcase_26 | AC | 416 ms
59,392 KB |
testcase_27 | AC | 436 ms
58,912 KB |
testcase_28 | AC | 364 ms
58,980 KB |
testcase_29 | AC | 357 ms
58,280 KB |
testcase_30 | AC | 368 ms
59,420 KB |
testcase_31 | AC | 373 ms
59,356 KB |
testcase_32 | AC | 364 ms
59,720 KB |
testcase_33 | AC | 370 ms
59,200 KB |
testcase_34 | AC | 409 ms
58,512 KB |
testcase_35 | AC | 379 ms
59,368 KB |
testcase_36 | AC | 424 ms
59,380 KB |
testcase_37 | AC | 395 ms
59,548 KB |
testcase_38 | AC | 429 ms
58,792 KB |
testcase_39 | AC | 454 ms
58,764 KB |
testcase_40 | AC | 395 ms
58,680 KB |
testcase_41 | AC | 414 ms
59,516 KB |
testcase_42 | AC | 353 ms
58,828 KB |
testcase_43 | AC | 369 ms
58,352 KB |
testcase_44 | AC | 419 ms
59,564 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); int[] colors = new int[n]; for (int i = 0; i < n; i++) { colors[i] = sc.nextInt() - 1; } long[] costs = new long[m]; long[] colorCosts = new long[m]; for (int i = 0; i < m; i++) { costs[i] = sc.nextInt(); colorCosts[i] = costs[i] * k; } for (int i = 0; i < k; i++) { colorCosts[colors[i]] -= costs[colors[i]]; } long ans = Long.MAX_VALUE; for (long x : colorCosts) { ans = Math.min(ans, x); } for (int i = k; i < n; i++) { colorCosts[colors[i - k]] += costs[colors[i - k]]; colorCosts[colors[i]] -= costs[colors[i]]; ans = Math.min(ans, colorCosts[colors[i]]); } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }