結果
| 問題 |
No.505 カードの数式2
|
| コンテスト | |
| ユーザー |
Kmcode1
|
| 提出日時 | 2017-04-21 23:02:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 1,499 ms |
| コンパイル使用メモリ | 167,036 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-20 06:36:35 |
| 合計ジャッジ時間 | 3,748 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 RE * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define MAX 16
vector<int> v;
vector<long long int> s[MAX];
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;
s[0].push_back(v[0]);
for (int i = 0; i < bet; i++){
sort(s[i].begin(), s[i].end());
for (int j = 0; j < s[i].size(); j++){
if (j>0 && j + 1 < s[i].size()&&s[i][j]!=0&&s[i][j+1]!=0&&s[i][j-1]!=0){
long long int ty = s[i][j] / abs(s[i][j]);
long long int ty1 = s[i][j - 1] / abs(s[i][j - 1]);
long long int ty2 = s[i][j + 1] / abs(s[i][j + 1]);
if (ty == ty1&&ty == ty2)continue;
}
s[i + 1].push_back(s[i][j] * v[i + 1]);
s[i + 1].push_back(s[i][j] / v[i + 1]);
s[i + 1].push_back(s[i][j] + v[i + 1]);
s[i + 1].push_back(s[i][j] - v[i + 1]);
}
}
sort(s[bet].begin(), s[bet].end());
printf("%lld\n", s[bet].back());
return 0;
}
Kmcode1