結果
| 問題 |
No.568 じゃんじゃん 落とす 委員会
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-01-30 19:04:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,979 bytes |
| コンパイル時間 | 4,433 ms |
| コンパイル使用メモリ | 78,352 KB |
| 実行使用メモリ | 60,076 KB |
| 最終ジャッジ日時 | 2024-09-16 03:46:37 |
| 合計ジャッジ時間 | 12,726 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
import java.util.*;
import java.io.*;
public class Main {
static int[] dp;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] first = br.readLine().split(" ", 2);
int n = Integer.parseInt(first[0]);
int m = Integer.parseInt(first[1]);
PriorityQueue<Person> aQueue = new PriorityQueue<Person>(new Comparator<Person>() {
public int compare(Person p1, Person p2) {
return p1.a - p2.a;
}
});
PriorityQueue<Person> bQueue = new PriorityQueue<Person>(new Comparator<Person>() {
public int compare(Person p1, Person p2) {
return p2.b - p1.b;
}
});
int comp3 = 0;
int comp2 = 0;
for (int i = 0; i < n; i++) {
Person p = new Person(br.readLine());
if (p.count >= 3) {
comp3++;
comp2++;
continue;
} else if (p.count >= 2) {
comp3++;
comp2++;
} else if (p.count >= 1) {
comp2++;
}
aQueue.add(p);
bQueue.add(p);
}
int min = comp3;
while (true) {
if (comp2 < m) {
if (bQueue.size() == 0) {
break;
}
int tmp = bQueue.peek().b;
while (bQueue.size() > 0 && tmp == bQueue.peek().b) {
Person p = bQueue.poll();
p.count++;
if (p.count == 2) {
comp3++;
} else if (p.count == 1) {
comp2++;
}
}
} else {
min = Math.min(min, comp3);
if (aQueue.size() == 0) {
break;
}
int tmp = aQueue.peek().a;
while (aQueue.size() > 0 && tmp == aQueue.peek().a) {
Person p = aQueue.poll();
p.count--;
if (p.count == 1) {
comp3--;
} else if (p.count == 0) {
comp2--;
}
}
}
}
System.out.println(min);
}
static class Person {
int a;
int b;
int count;
public Person(int count, int a, int b) {
this.a = a;
this.b = b;
this.count = count;
}
public Person(String a, String b, String c) {
this(Integer.parseInt(a), Integer.parseInt(b), Integer.parseInt(c));
}
public Person(String[] arr) {
this(arr[0], arr[1], arr[2]);
}
public Person(String s) {
this(s.split(" ", 3));
}
}
}
htensai