結果

問題 No.505 カードの数式2
ユーザー どららどらら
提出日時 2017-04-21 22:34:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 856 bytes
コンパイル時間 2,484 ms
コンパイル使用メモリ 180,400 KB
実行使用メモリ 364,020 KB
最終ジャッジ日時 2023-10-25 06:43:49
合計ジャッジ時間 9,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 14 ms
6,632 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 599 ms
95,640 KB
testcase_23 AC 85 ms
20,092 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 914 ms
127,480 KB
testcase_27 AC 1,039 ms
130,960 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
  }

  map<ll,int> memo;
  memo[v[0]] = 1;
  REP(i,1,N){
    map<ll,int> tmp;
    FOR(it,memo){
      //+
      tmp[it->first + v[i]] = 1;
      //-
      tmp[it->first - v[i]] = 1;
      //*
      tmp[it->first * v[i]] = 1;
      //div
      if(v[i]!=0){
        tmp[it->first / v[i]] = 1;
      }
    }
    memo = tmp;
  }

  ll mx = -1000000000000000000LL;
  FOR(it,memo){
    mx = max(mx, it->first);
  }
  cout << mx << endl;
  
  return 0;
}

0