結果
問題 |
No.1816 MUL-DIV Game
|
ユーザー |
![]() |
提出日時 | 2022-01-21 21:36:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 3,864 ms |
コンパイル使用メモリ | 88,132 KB |
実行使用メモリ | 60,612 KB |
最終ジャッジ日時 | 2024-11-25 23:00:46 |
合計ジャッジ時間 | 18,720 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 9 WA * 18 |
ソースコード
import java.io.BufferedInputStream; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] argv){ Scanner sc = new Scanner(new BufferedInputStream(System.in)); int n = sc.nextInt(); long[] a= new long[n]; for(int i = 0 ; i < n ; i++){ a[i] = sc.nextLong(); } if (n == 1) System.out.println(a[0]); PriorityQueue<Long> que = new PriorityQueue<>((x, y)-> Long.compare(y, x)); for(int i = 0 ; i< n; i++){ que.add(a[i]); } int t = 0; while(que.size()>1){ long x = que.poll(), y = que.poll(); if (t==0){ que.add(x*y); }else{ que.add((y+x-1)/x); } t^=1; } System.out.println(que.poll()); } }