結果

問題 No.1816 MUL-DIV Game
ユーザー ripity
提出日時 2022-01-21 22:33:28
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 932 bytes
コンパイル時間 2,552 ms
コンパイル使用メモリ 76,692 KB
実行使用メモリ 61,004 KB
最終ジャッジ日時 2024-11-26 01:29:56
合計ジャッジ時間 15,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    
    public static Scanner sc = new Scanner(System.in);
    public static PrintWriter pw = new PrintWriter(System.out);
    
    public static void main(String[] args) {
        
        int T = 1;
        while( T > 0 ) {
            solve();
            T--;
        }
        
        pw.flush();
        
    }
    
    static void solve() {
        
        int N = sc.nextInt();
        PriorityQueue<Long> pqueue = new PriorityQueue<>(Collections.reverseOrder());
        for( int i = 0; i < N; i++ ) {
            long a = sc.nextInt();
            pqueue.offer(a);
        }
        
        for( int i = 0; i < N-1; i++ ) {
            long p = pqueue.poll();
            long q = pqueue.poll();
            if( i%2 == 0 ) pqueue.offer(p*q);
            else pqueue.offer((q+p-1)/p);
        }
        
        pw.println(pqueue.poll());
        
    }
    
}
0