結果

問題 No.2566 美しい整数列
ユーザー viral8viral8
提出日時 2023-12-02 15:52:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 754 ms / 2,000 ms
コード長 1,113 bytes
コンパイル時間 3,195 ms
コンパイル使用メモリ 85,204 KB
実行使用メモリ 96,756 KB
最終ジャッジ日時 2023-12-02 15:53:08
合計ジャッジ時間 17,258 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
54,376 KB
testcase_01 AC 56 ms
54,260 KB
testcase_02 AC 54 ms
54,344 KB
testcase_03 AC 53 ms
54,360 KB
testcase_04 AC 709 ms
95,716 KB
testcase_05 AC 714 ms
89,456 KB
testcase_06 AC 631 ms
83,300 KB
testcase_07 AC 609 ms
87,512 KB
testcase_08 AC 608 ms
87,432 KB
testcase_09 AC 586 ms
83,428 KB
testcase_10 AC 619 ms
83,336 KB
testcase_11 AC 656 ms
87,972 KB
testcase_12 AC 686 ms
88,884 KB
testcase_13 AC 754 ms
87,860 KB
testcase_14 AC 670 ms
88,016 KB
testcase_15 AC 724 ms
88,932 KB
testcase_16 AC 627 ms
88,476 KB
testcase_17 AC 710 ms
96,756 KB
testcase_18 AC 693 ms
89,016 KB
testcase_19 AC 599 ms
84,092 KB
testcase_20 AC 640 ms
90,124 KB
testcase_21 AC 720 ms
90,100 KB
testcase_22 AC 571 ms
78,660 KB
testcase_23 AC 632 ms
91,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
class Main{
	private static final BufferedReader br =
		new BufferedReader(new InputStreamReader(System.in));
	private static final PrintWriter out =
		new PrintWriter(System.out);
	public static void main(String[] args)throws IOException{

		String[] str = br.readLine().split(" ");
		int N = Integer.parseInt(str[0]);
		int M = Integer.parseInt(str[1]);
		str = br.readLine().split(" ");
		int[] A = new int[N];
		for(int i=0;i<N;i++)
			A[i] = Integer.parseInt(str[i]);
		str = br.readLine().split(" ");
		int[] B = new int[M];
		for(int i=0;i<M;i++)
			B[i] = Integer.parseInt(str[i]);
		str = br.readLine().split(" ");
		int[] C = new int[N];
		for(int i=0;i<N;i++)
			C[i] = Integer.parseInt(str[i]);
		HashMap<Long,Long> map = new HashMap<>();
		long now = A[0];
		map.put(0L,(long)C[0]);
		for(int i=1;i<N;i++){
			now += B[(i-1)%M];
			map.merge(now-A[i],(long)C[i],Long::sum);
		}
		long sumC = 0;
		for(long num:C)
			sumC += num;
		long max = 0;
		for(long num:map.values())
			max = Math.max(num,max);
		out.println(sumC-max);

		br.close();
		out.close();
	}
}
0