結果
問題 | No.2453 Seat Allocation |
ユーザー | tenten |
提出日時 | 2024-04-03 14:18:44 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 576 ms / 2,000 ms |
コード長 | 2,463 bytes |
コンパイル時間 | 2,540 ms |
コンパイル使用メモリ | 80,156 KB |
実行使用メモリ | 68,996 KB |
最終ジャッジ日時 | 2024-04-03 14:18:59 |
合計ジャッジ時間 | 13,524 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
54,104 KB |
testcase_01 | AC | 54 ms
54,136 KB |
testcase_02 | AC | 55 ms
54,096 KB |
testcase_03 | AC | 56 ms
54,116 KB |
testcase_04 | AC | 57 ms
54,096 KB |
testcase_05 | AC | 524 ms
68,760 KB |
testcase_06 | AC | 312 ms
61,952 KB |
testcase_07 | AC | 265 ms
63,660 KB |
testcase_08 | AC | 170 ms
57,964 KB |
testcase_09 | AC | 517 ms
68,996 KB |
testcase_10 | AC | 571 ms
68,968 KB |
testcase_11 | AC | 576 ms
68,708 KB |
testcase_12 | AC | 306 ms
61,860 KB |
testcase_13 | AC | 324 ms
61,876 KB |
testcase_14 | AC | 286 ms
61,832 KB |
testcase_15 | AC | 409 ms
61,668 KB |
testcase_16 | AC | 295 ms
60,068 KB |
testcase_17 | AC | 56 ms
54,112 KB |
testcase_18 | AC | 429 ms
66,100 KB |
testcase_19 | AC | 499 ms
66,056 KB |
testcase_20 | AC | 321 ms
60,472 KB |
testcase_21 | AC | 327 ms
63,828 KB |
testcase_22 | AC | 409 ms
65,900 KB |
testcase_23 | AC | 56 ms
54,096 KB |
testcase_24 | AC | 55 ms
54,072 KB |
ソースコード
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(); } } }