結果

問題 No.206 数の積集合を求めるクエリ
ユーザー kenkoooo
提出日時 2015-05-09 00:55:51
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 712 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 76,704 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-07-05 20:55:01
合計ジャッジ時間 24,977 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 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]++;
				}
			}
		}

		for (int i = 0; i < cnt.length; i++) {
			System.out.println(cnt[i]);
		}

	}
}
0