結果
問題 | No.2453 Seat Allocation |
ユーザー | tenten |
提出日時 | 2023-09-04 13:09:53 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 553 ms / 2,000 ms |
コード長 | 2,904 bytes |
コンパイル時間 | 3,071 ms |
コンパイル使用メモリ | 95,760 KB |
実行使用メモリ | 68,920 KB |
最終ジャッジ日時 | 2024-06-25 09:38:34 |
合計ジャッジ時間 | 10,823 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
50,500 KB |
testcase_01 | AC | 53 ms
50,420 KB |
testcase_02 | AC | 53 ms
50,528 KB |
testcase_03 | AC | 53 ms
50,540 KB |
testcase_04 | AC | 53 ms
50,336 KB |
testcase_05 | AC | 495 ms
68,920 KB |
testcase_06 | AC | 301 ms
56,548 KB |
testcase_07 | AC | 244 ms
60,940 KB |
testcase_08 | AC | 159 ms
55,848 KB |
testcase_09 | AC | 507 ms
65,264 KB |
testcase_10 | AC | 510 ms
65,936 KB |
testcase_11 | AC | 553 ms
66,872 KB |
testcase_12 | AC | 299 ms
56,692 KB |
testcase_13 | AC | 301 ms
56,508 KB |
testcase_14 | AC | 281 ms
56,524 KB |
testcase_15 | AC | 345 ms
60,296 KB |
testcase_16 | AC | 282 ms
56,536 KB |
testcase_17 | AC | 54 ms
50,416 KB |
testcase_18 | AC | 405 ms
60,204 KB |
testcase_19 | AC | 447 ms
62,424 KB |
testcase_20 | AC | 299 ms
56,868 KB |
testcase_21 | AC | 325 ms
60,092 KB |
testcase_22 | AC | 380 ms
60,192 KB |
testcase_23 | AC | 53 ms
50,264 KB |
testcase_24 | AC | 52 ms
50,396 KB |
ソースコード
import java.io.*; import java.util.*; 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(); int[] parties = new int[n]; for (int i = 0; i < n; i++) { parties[i] = sc.nextInt(); } int[] times = new int[m + 1]; for (int i = 0; i < m; i++) { times[i] = sc.nextInt(); } times[m] = Integer.MAX_VALUE; int[] idxes = new int[n]; PriorityQueue<Result> results = new PriorityQueue<>(); for (int i = 0; i < n; i++) { results.add(new Result(i, parties[i], times[0])); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < m; i++) { Result x = results.poll(); sb.append(x.idx + 1).append("\n"); idxes[x.idx]++; results.add(new Result(x.idx, parties[x.idx], times[idxes[x.idx]])); } System.out.print(sb); } static class Result implements Comparable<Result> { int idx; long value; long base; public Result(int idx, long value, long base) { this.idx = idx; this.value = value; this.base = base; } public int compareTo(Result another) { long comp = value * another.base - another.value * base; if (comp == 0) { return idx - another.idx; } else if (comp < 0) { return 1; } else { return -1; } } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }