結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-31 01:05:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 487 bytes |
| コンパイル時間 | 3,541 ms |
| コンパイル使用メモリ | 191,796 KB |
| 最終ジャッジ日時 | 2025-01-10 19:45:18 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | int n,a[16]; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | rep(i,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int main(){
int n,a[16]; scanf("%d",&n);
rep(i,n) scanf("%d",&a[i]);
lint mx[16],mn[16];
mx[0]=mn[0]=a[0];
for(int i=1;i<n;i++){
mx[i]=max({mx[i-1]+a[i],mx[i-1]-a[i],mx[i-1]*a[i]});
mn[i]=min({mn[i-1]+a[i],mn[i-1]-a[i],mn[i-1]*a[i]});
if(a[i]!=0){
mx[i]=max(mx[i],mx[i-1]/a[i]);
mn[i]=min(mn[i],mn[i-1]/a[i]);
}
}
printf("%lld\n",mx[n-1]);
return 0;
}