結果

問題 No.505 カードの数式2
ユーザー kurarrrkurarrr
提出日時 2017-04-21 23:01:29
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 736 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 81,720 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 12:27:40
合計ジャッジ時間 3,047 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7;
const int INF=1<<30;
const int MAX_N=100001;

int main(){
  int N;
  cin >> N ;
  ll ma=0,mi=0,a;
  rep(i,N){
    cin >> a ;
    ma=max(max(ma+a,ma*a),max(ma-a,mi*a));
    if(!a)  mi=min(min(mi+a,mi-a),min(mi/a,min(mi*a,ma*a)));
  }
  cout << ma;
  return 0;
}
0