結果
問題 |
No.505 カードの数式2
|
ユーザー |
![]() |
提出日時 | 2018-08-28 21:43:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 81,984 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 07:31:45 |
合計ジャッジ時間 | 1,639 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#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),x*a),max(max(y+a,y-a),y*a)); mi=min(min(min(x+a,x-a),x*a),min(min(y+a,y-a),y*a)); if(a){ ma=max(ma,max(x/a,y/a)); mi=min(mi,min(x/a,y/a)); } } cout<<ma<<endl; }