結果

問題 No.206 数の積集合を求めるクエリ
ユーザー kenkoooo
提出日時 2015-05-09 00:57:12
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 77,736 KB
実行使用メモリ 75,968 KB
最終ジャッジ日時 2024-07-05 20:55:43
合計ジャッジ時間 22,422 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 22 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int M = sc.nextInt();
		int N = sc.nextInt();

		boolean[] A = new boolean[N];
		for (int i = 0; i < L; i++) {
			A[sc.nextInt() - 1] = true;
		}
		boolean[] B = new boolean[N];
		for (int i = 0; i < M; i++) {
			B[sc.nextInt() - 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