結果
問題 | No.505 カードの数式2 |
ユーザー |
![]() |
提出日時 | 2017-04-21 23:06:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 627 bytes |
コンパイル時間 | 1,354 ms |
コンパイル使用メモリ | 165,952 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 15:13:26 |
合計ジャッジ時間 | 2,184 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 1 WA * 28 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i = n; i < (int) N; i++)#define ck(n,a,b) ((a)<=(n)&&(n)<(b))#define p(s) cout<<(s)<<endltypedef long long ll;const int inf=1e9;using namespace std;int main() {int N;cin>>N;int a[16];int ans=0;int minus=0;int mnx=-10;int m=-1;REP(i,0,N) {cin>>a[i];if(a[i]<0){if(mnx<a[i]){mnx=a[i];m=i;}minus++;}}REP(i,0,N){if(a[i]==0){continue;}else if(a[i]==1){ans++;}else if(m==i&&(minus%2)){ans-=a[i];}else{if(ans==0){ans+=a[i];}else ans*=a[i];}p(ans);}p(ans);return 0;}