結果
| 問題 | No.505 カードの数式2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-24 12:04:07 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 623 bytes |
| 記録 | |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 79,616 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 17:27:18 |
| 合計ジャッジ時間 | 1,723 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
using namespace std;
int main(){
int n;cin>>n;
long long z;cin>>z;
long long nwmx = z;
long long nwmn = z;
for(int i = 0; n-1 > i; i++){
long long x;cin>>x;
long long nexmx = max(nwmx+x,nwmn+x);
long long nexmn = min(nwmx+x,nwmn+x);
nexmx = max(nexmx,max(nwmx-x,nwmn-x));
nexmn = min(nexmn,min(nwmx-x,nwmn-x));
nexmx = max(nexmx,max(nwmx*x,nwmn*x));
nexmn = min(nexmn,min(nwmx*x,nwmn*x));
if(x!=0){
nexmx = max(nexmx,max(nwmx/x,nwmn/x));
nexmn = min(nexmn,min(nwmx/x,nwmn/x));
}
nwmx = nexmx;
nwmn = nexmn;
}
cout << nwmx << endl;
}