結果

問題 No.505 カードの数式2
ユーザー rikarika
提出日時 2017-04-21 22:58:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-27 12:25:28
合計ジャッジ時間 1,578 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int ans1=a[0];
  int ans2=ans1;
  for(i=1;i<n;i++){
    int x1=ans1+a[i];
    int y1=ans1-a[i];
    int z1=ans1*a[i];
    int x2=ans2+a[i];
    int y2=ans2-a[i];
    int z2=ans2*a[i];
    ans1=x1;
    ans2=x1;
    ans1=max(ans1,y1);
    ans2=min(ans2,y1);
    ans1=max(ans1,z1);
    ans2=min(ans2,z1);
    ans1=max(ans1,x1);
    ans2=min(ans2,x1);
    ans1=max(ans1,y1);
    ans2=min(ans2,y1);
    ans1=max(ans1,z1);
    ans2=min(ans2,z1);
  }
  cout<<ans1<<endl;

}
0