結果
| 問題 |
No.647 明太子
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-04 17:57:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 467 ms / 4,500 ms |
| コード長 | 1,227 bytes |
| コンパイル時間 | 2,299 ms |
| コンパイル使用メモリ | 79,408 KB |
| 実行使用メモリ | 52,688 KB |
| 最終ジャッジ日時 | 2024-11-26 08:43:25 |
| 合計ジャッジ時間 | 8,389 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import java.util.*;
public class Main {
static final long MAX = (long)Math.sqrt(Long.MAX_VALUE);
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] costs = new int[n];
int[] hots = new int[n];
for (int i = 0; i < n; i++) {
costs[i] = sc.nextInt();
hots[i] = sc.nextInt();
}
int m = sc.nextInt();
int[] counts = new int[m];
for (int i = 0; i < m; i++) {
int c = sc.nextInt();
int h = sc.nextInt();
for (int j = 0; j < n; j++) {
if (c <= costs[j] && h >= hots[j]) {
counts[i]++;
}
}
}
int max = 0;
ArrayList<Integer> list = new ArrayList<>();
for (int i = 0; i < m; i++) {
if (counts[i] > max) {
list.clear();
list.add(i + 1);
max = counts[i];
} else if (counts[i] == max) {
list.add(i + 1);
}
}
if (max == 0) {
System.out.println(0);
return;
}
StringBuilder sb = new StringBuilder();
for (int x : list) {
sb.append(x).append("\n");
}
System.out.print(sb);
}
}
tenten