結果

問題 No.505 カードの数式2
ユーザー nxterunxteru
提出日時 2018-08-28 21:42:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 658 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 79,996 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 08:00:53
合計ジャッジ時間 3,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll n,ma,mi;
int main(void){
    cin>>n>>ma;
    mi=ma;
    for(int i=1;i<n;i++){
        ll a;
        cin>>a;
        ll x=ma,y=mi;
        ma=max(max(max(x+a,x-a),max(x*a,x/a)),max(max(y+a,y-a),max(y*a,y/a)));
        mi=min(min(min(x+a,x-a),min(x*a,x/a)),min(min(y+a,y-a),min(y*a,y/a)));
    }
    cout<<ma<<endl;
}
0