結果

問題 No.1816 MUL-DIV Game
コンテスト
ユーザー SamShawCraft
提出日時 2022-01-21 23:08:16
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 533 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 498 ms
コンパイル使用メモリ 97,132 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-25 02:04:07
合計ジャッジ時間 1,879 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 9 WA * 15 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <functional>
#include <algorithm>
#include <cmath>
#define qaq inline
const int sz=1e5+19;
using ll=long long;
int n;
ll ans=0,arr[sz];
int main(){
  scanf("%d",&n);
  for(int cx=0;cx<n;++cx)
    scanf("%d",arr+cx);
  if(n==1) return printf("%d\n",arr[0]);
  std::sort(arr,arr+n,std::greater<int>());
  int p1=0,p2=n-1,flag=1;
  while(p1<p2){
    if(flag) ans=arr[p1]=1LL*arr[p1]*arr[p2],p2--;
    else ans=arr[p2]=std::ceil(arr[p2]*1.0/arr[p1]),p1++;
    flag^=1;
  }
  printf("%lld",ans);
  return 0;
}
0