結果

問題 No.505 カードの数式2
ユーザー tomokinextomokinex
提出日時 2017-06-22 16:12:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 3,640 ms
コンパイル使用メモリ 55,852 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 10:29:16
合計ジャッジ時間 1,491 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 WA -
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 2 ms
6,948 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int main(){
  int n,m,ans[2],a[8];
  cin >> n;
  cin >> m;
  ans[0] = m;
  ans[1] = m;
  for(int i=1;i<n;i++){
    cin >> m;
    for(int j=0;j<2;j++){
      a[4*j] = ans[j]+m;
      a[4*j+1] = ans[j]-m;
      a[4*j+2] = ans[j]*m;
      a[4*j+3] = (m!=0)?ans[j]/m:a[4*j];
    }
    ans[0] = a[0];
    ans[1] = a[1];
    for(int j=1;j<8;j++){
      if(a[j]>ans[0]){
        ans[0] = a[j];
      }
      if(a[j]<ans[1]){
        ans[1] = a[j];
      }
    }
  }
  cout << ans[0] << endl;
}
0