結果

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

ソースコード

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