結果
| 問題 |
No.989 N×Mマス計算(K以上)
|
| コンテスト | |
| ユーザー |
silviasetitech
|
| 提出日時 | 2020-03-05 10:13:11 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 998 ms / 2,000 ms |
| コード長 | 2,197 bytes |
| コンパイル時間 | 2,863 ms |
| コンパイル使用メモリ | 79,312 KB |
| 実行使用メモリ | 61,380 KB |
| 最終ジャッジ日時 | 2024-10-14 00:50:35 |
| 合計ジャッジ時間 | 12,848 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author silviase
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
nmCalc solver = new nmCalc();
solver.solve(1, in, out);
out.close();
}
static class nmCalc {
public void solve(int testNumber, Scanner in, PrintWriter out) {
// 愚直だと死んでしまうので二分探索かしゃくとりだけど尺取り法でよさそう…?
// どっちも出してどっちもACすればええやん!人生は冒険や!
int n = in.nextInt();
int m = in.nextInt();
int k = in.nextInt();
long ans = 0;
String op = in.next();
ArrayList<Long> min2max = new ArrayList<>();
ArrayList<Long> max2min = new ArrayList<>();
for (int i = 0; i < m; i++) {
min2max.add(in.nextLong());
}
for (int i = 0; i < n; i++) {
max2min.add(in.nextLong());
}
min2max.sort(Comparator.naturalOrder());
max2min.sort(Comparator.reverseOrder());
int index = 0;
for (Long l : min2max) {
while (index < n) {
if (op.charAt(0) == '+') {
if (l + max2min.get(index) < k) {
break;
}
} else if (op.charAt(0) == '*') {
if (l * max2min.get(index) < k) {
break;
}
}
index++;
}
ans += index;
// out.println(ans);
}
out.println(ans);
}
}
}
silviasetitech