結果

問題 No.206 数の積集合を求めるクエリ
ユーザー kenkooookenkoooo
提出日時 2015-05-09 01:00:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,047 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 74,496 KB
実行使用メモリ 72,652 KB
最終ジャッジ日時 2023-09-19 09:11:44
合計ジャッジ時間 20,443 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] first = sc.nextLine().split(" ");
		int L = Integer.parseInt(first[0]);
		int M = Integer.parseInt(first[1]);
		int N = Integer.parseInt(first[2]);

		boolean[] A = new boolean[N];
		String[] aStrings = sc.nextLine().split(" ");
		for (int i = 0; i < aStrings.length; i++) {
			A[Integer.parseInt(aStrings[i]) - 1] = true;
		}
		boolean[] B = new boolean[N];
		String[] bStrings = sc.nextLine().split(" ");
		for (int i = 0; i < bStrings.length; i++) {
			A[Integer.parseInt(bStrings[i]) - 1] = true;
		}

		int Q = sc.nextInt();
		sc.close();

		int[] cnt = new int[Q];
		for (int i = 0; i < N; i++) {
			for (int q = 0; q < Q; q++) {
				if (i + q >= N) {
					break;
				}
				if (A[i + q] && B[i]) {
					cnt[q]++;
				}
			}
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < cnt.length; i++) {
			sb.append(cnt[i]);
			sb.append("\n");
		}
		System.out.println(sb.toString());

	}
}
0