結果

問題 No.505 カードの数式2
ユーザー vjudge1
提出日時 2025-06-20 22:56:32
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,360 bytes
コンパイル時間 2,955 ms
コンパイル使用メモリ 275,248 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-06-20 22:56:37
合計ジャッジ時間 4,243 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
??????
??????
??????
??????
D P ????
??????
??????
??????
??????
??? l l?
??????
??????
?? OI ??
??????
*/
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
   while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
   return x*f;
}
void write(int x)
{
   if(x<0)putchar('-'),x=-x;
   if(x<10)putchar(x+'0');
   else write(x/10),putchar(x%10+'0');
}
const int N=1e1;
const int mod=1e9+7;
//const int mod=998244353;
void T_(){
   int sum=0;
   while(sum<=3e9)sum++;
}
void point(){

}
void clear(){

}
int a[100];
void solve(){
	int n=read(); 
	for(int i=1;i<=n;i++)a[i]=read();
	int minn=a[1];
	int maxn=a[1];
	for(int i=2;i<=n;i++){
		
		maxn=max(maxn*a[i],max(minn*a[i],max(maxn+a[i],maxn-a[i])));
		if(a[i]!=0)maxn=max(maxn,maxn/a[i]);
		minn=min(maxn*a[i],min(minn*a[i],min(minn+a[i],minn-a[i])));
	}
	cout<<maxn<<"\n";
}
signed main(){
   int T=1;
//   cin>>T;
   while(T--)solve();
   return 0;
}
// ?????????????AC????
// ?????????????????????????
// ??????????????????
// ????????????????????????????????????
// ???????????????????????????????
// ????????????
// ????????????
// ????????????
// ????????????????????
// ????????????????????
// ????????????????????????????????
// ???????????????????????
// ???????????
// ?????????????
0