結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
Kmcode1
|
| 提出日時 | 2017-04-21 22:58:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 586 bytes |
| コンパイル時間 | 1,191 ms |
| コンパイル使用メモリ | 159,564 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 06:32:35 |
| 合計ジャッジ時間 | 2,132 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 2 WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define MAX 16
vector<int> v;
int main(){
int way = 1;
int n;
cin >> n;
for (int i = 0; i < n; i++){
int a;
scanf("%d", &a);
v.push_back(a);
}
int bet = n - 1;
for (int i = 0; i < bet; i++){
way *= 2;
}
long long int ans = LLONG_MIN;
for (int i = 0; i < way; i++){
long long int sum = v[0];
for (int j = 0; j < bet; j++){
if ((i >> j) & 1){
sum *= v[j];
}
else{
sum += abs(v[j]);
}
}
ans = max(ans, sum);
}
printf("%lld\n", ans);
return 0;
}
Kmcode1