結果

問題 No.1816 MUL-DIV Game
ユーザー SamShawCraft
提出日時 2022-01-21 22:17:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 502 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 75,500 KB
最終ジャッジ日時 2025-01-27 13:56:42
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 3 WA * 21 RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d",arr+cx);
      |     ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

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