結果

問題 No.505 カードの数式2
ユーザー kurarrrkurarrr
提出日時 2017-04-21 23:37:19
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 82,336 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-21 06:06:38
合計ジャッジ時間 1,619 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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;
  cin >> a ;
  ma=mi=a;
  REP(i,1,N){
    cin >> a ;
    ll temp=mi;
    if(a){
      ma=max(max(ma+a,ma*a),max(ma-a,max(mi*a,ma/a)));
      mi=min(min(mi+a,mi-a),min(mi/a,min(mi*a,temp*a)));
    }else{
      ma=max(ma,0LL);
      mi=min(mi,0LL);
    }
    //cout << ma << " "<<mi << endl;
  }
  cout << ma << endl;
  return 0;
}
0