結果

問題 No.989 N×Mマス計算(K以上)
ユーザー ks2mks2m
提出日時 2020-02-14 21:43:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 1,010 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 77,780 KB
実行使用メモリ 52,204 KB
最終ジャッジ日時 2024-04-16 01:42:30
合計ジャッジ時間 6,558 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
37,156 KB
testcase_01 AC 55 ms
37,224 KB
testcase_02 AC 57 ms
37,052 KB
testcase_03 AC 59 ms
37,012 KB
testcase_04 AC 57 ms
37,104 KB
testcase_05 AC 56 ms
37,104 KB
testcase_06 AC 57 ms
37,260 KB
testcase_07 AC 59 ms
37,256 KB
testcase_08 AC 58 ms
37,264 KB
testcase_09 AC 56 ms
37,140 KB
testcase_10 AC 326 ms
48,404 KB
testcase_11 AC 308 ms
48,324 KB
testcase_12 AC 322 ms
48,316 KB
testcase_13 AC 250 ms
46,500 KB
testcase_14 AC 387 ms
52,204 KB
testcase_15 AC 208 ms
43,112 KB
testcase_16 AC 286 ms
46,820 KB
testcase_17 AC 235 ms
46,352 KB
testcase_18 AC 225 ms
44,976 KB
testcase_19 AC 312 ms
49,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		String s = sa[0];
		double[] b = new double[m];
		for (int i = 0; i < b.length; i++) {
			b[i] = Long.parseLong(sa[i + 1]);
		}
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = Long.parseLong(br.readLine());
		}
		br.close();

		Arrays.parallelSort(a);
		Arrays.parallelSort(b);

		long ans = 0;
		for (int i = 0; i < a.length; i++) {
			long v = 0;
			if ("+".equals(s)) {
				v = k - a[i];
			} else {
				v = (k + a[i] - 1) / a[i];
			}
			int idx = Arrays.binarySearch(b, v - 0.5);
			idx = ~idx;
			ans += m - idx;
		}
		System.out.println(ans);
	}
}
0