結果

問題 No.1816 MUL-DIV Game
コンテスト
ユーザー koanviolin
提出日時 2022-01-21 21:36:35
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 872 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,151 ms
コンパイル使用メモリ 91,712 KB
実行使用メモリ 60,440 KB
最終ジャッジ日時 2026-09-30 02:13:42
合計ジャッジ時間 12,358 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 9 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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());

    }
}
0