結果
問題 | No.989 N×Mマス計算(K以上) |
ユーザー |
![]() |
提出日時 | 2020-02-21 08:41:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 772 ms / 2,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 3,247 ms |
コンパイル使用メモリ | 78,156 KB |
実行使用メモリ | 60,884 KB |
最終ジャッジ日時 | 2024-10-08 19:46:06 |
合計ジャッジ時間 | 10,632 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); char op = sc.next().charAt(0); long[] arrB = new long[m]; for (int i = 0; i < m; i++) { arrB[i] = sc.nextInt(); } Arrays.sort(arrB); long[] arrA = new long[n]; for (int i = 0; i < n; i++) { arrA[i] = sc.nextInt(); } Arrays.sort(arrA); int idxB = m - 1; long count = 0; if (op == '+') { for (int i = 0; i < n; i++) { while (idxB >= 1 && arrB[idxB - 1] + arrA[i] >= k) { idxB--; } if (arrB[idxB] + arrA[i] >= k) { count += m - idxB; } } } else { for (int i = 0; i < n; i++) { while (idxB >= 1 && arrB[idxB - 1] * arrA[i] >= k) { idxB--; } if (arrB[idxB] * arrA[i] >= k) { count += m - idxB; } } } System.out.println(count); } }