結果

問題 No.206 数の積集合を求めるクエリ
ユーザー kenkooookenkoooo
提出日時 2015-05-09 01:06:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,146 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 101,628 KB
最終ジャッジ日時 2023-09-19 09:12:30
合計ジャッジ時間 17,130 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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.io.IOException;

public class Main {

	public static void main(String[] args) {
		int L = nextInt();
		int M = nextInt();
		int N = nextInt();

		boolean[] A = new boolean[N];
		for (int i = 0; i < L; i++) {
			A[nextInt() - 1] = true;
		}
		boolean[] B = new boolean[N];
		for (int i = 0; i < M; i++) {
			B[nextInt() - 1] = true;
		}

		int Q = nextInt();

		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());

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return -1;
	}

}
0