結果

問題 No.206 数の積集合を求めるクエリ
コンテスト
ユーザー kenkoooo
提出日時 2015-05-09 00:57:12
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 802 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,852 ms
コンパイル使用メモリ 82,968 KB
実行使用メモリ 99,972 KB
最終ジャッジ日時 2026-03-27 06:40:11
合計ジャッジ時間 22,815 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 22 TLE * 2 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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