結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-04-22 15:52:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 1,506 ms |
| コンパイル使用メモリ | 167,456 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-21 16:09:50 |
| 合計ジャッジ時間 | 2,663 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 17 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;
int main(){
int n;
cin>>n;
ll mx=0,mn=0;
REP(i,0,n){
int a;
cin>>a;
ll tmx,tmn;
tmx=max( max(mx-a ,max(mx+a ,mx*a)) , max(mn-a ,max(mn+a ,mn*a)) );
tmn=min( min(mx-a ,min(mx+a ,mx*a)) , min(mn-a ,min(mn+a ,mn*a)) );
if(a!=0) {
tmx=max(tmx,mx/a);
tmn=min(tmn,mn/a);
}
mx=tmx;
mn=tmn;
}
p(mx);
return 0;
}
dnish