結果
| 問題 |
No.2453 Seat Allocation
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2024-04-03 14:18:44 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 557 ms / 2,000 ms |
| コード長 | 2,463 bytes |
| コンパイル時間 | 3,701 ms |
| コンパイル使用メモリ | 81,856 KB |
| 実行使用メモリ | 58,360 KB |
| 最終ジャッジ日時 | 2025-06-20 02:06:38 |
| 合計ジャッジ時間 | 12,230 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
int m = sc.nextInt();
List<Party> parties = new ArrayList<>();
for (int i = 0; i < n; i++) {
parties.add(new Party(i, sc.nextInt()));
}
Party.base = new long[m + 1];
for (int i = 0; i < m; i++) {
Party.base[i] = sc.nextInt();
}
PriorityQueue<Party> queue = new PriorityQueue<>(parties);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < m; i++) {
Party x = queue.poll();
sb.append(x).append("\n");
x.add();
queue.add(x);
}
System.out.print(sb);
}
static class Party implements Comparable<Party> {
static long[] base;
int idx;
int value;
int current;
public Party(int idx, int value) {
this.idx = idx;
this.value = value;
}
public int compareTo(Party another) {
int ans = Long.compare(another.value * base[current], value * base[another.current]);
if (ans == 0) {
return idx - another.idx;
} else {
return ans;
}
}
public String toString() {
return String.valueOf(idx + 1);
}
public void add() {
current++;
}
}
}
class Scanner {
BufferedReader br;
StringTokenizer st = new StringTokenizer("");
StringBuilder sb = new StringBuilder();
public Scanner() {
try {
br = new BufferedReader(new InputStreamReader(System.in));
} catch (Exception e) {
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String next() {
try {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return st.nextToken();
}
}
}
tenten