結果

問題 No.1594 Three Classes
ユーザー Cyclone28Cyclone28
提出日時 2021-07-09 22:03:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 4,968 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 168,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-10 06:51:16
合計ジャッジ時間 2,935 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 31 ms
4,380 KB
testcase_04 AC 31 ms
4,380 KB
testcase_05 AC 31 ms
4,376 KB
testcase_06 AC 32 ms
4,376 KB
testcase_07 AC 31 ms
4,380 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 31 ms
4,376 KB
testcase_10 AC 31 ms
4,380 KB
testcase_11 AC 32 ms
4,380 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 31 ms
4,380 KB
testcase_16 AC 12 ms
4,380 KB
testcase_17 AC 32 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif
#if __cplusplus >= 201703L
#include <any>
#include <charconv>
// #include <execution>
#include <filesystem>
#include <optional>
//#include <memory_resource>
#include <string_view>
#include <variant>
#endif
#if __cplusplus > 201703L
#include <barrier>
#include <bit>
#include <compare>
#include <concepts>
#if __cpp_impl_coroutine
#include <coroutine>
#endif
#include <latch>
#include <numbers>
#include <ranges>
#include <span>
#include <stop_token>
#include <semaphore>
#include <source_location>
#include <syncstream>
#include <version>
#endif
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

//#define int ll

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

#define rep1(i, n) for(ll i = 0; i < (int)(n); i++)
#define rep2(i, a, b) for(ll i = (int)(a); i < (int)(b); i++)
#define rep3(i, a, b, c) for(ll i = (int)(a); i < (int)(b); i+=(int)(c))
#define rrep1(i, n) for(ll i = (int)(n); i >= 0; i--)
#define rrep2(i, a, b) for(ll i = (int)(b); i >= (int)(a); i--)
#define REP(i) for(ll i = 0; ; i++)
#define all(v) (v).begin(), (v).end()

template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }
template<class T> ll sum(const T& a){ return accumulate(all(a), 0LL); }
template<class T> ld dsum(const T& a){ return accumulate(all(a), 0.0L); }

const int MOD = 1000000007;
const int MMOD = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll POW(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll MODPOW(ll a, ll b){ ll ret = 1; while(b){ if(b & 1) ret = ret*a%MOD; a = a*a%MOD; b /= 2;} return ret;}

/*
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
//*/

/*
struct Edge{
  ll to;
  ll we;
  t(ll s, ll t) : to(s), we(t) {}
};
using Graph = vector<vector<Edge>>;
//*/

/*
#include<atcoder/all>
using namespace atcoder;
//*/

/*
ll op(ll a, ll b) { return a+b; }
ll e() { return 0; }
//*/

ll N;

bool dfs(vector<ll> E, vector<ll> &A, vector<ll> &B, vector<ll> &C, int now){
  if(A.size()+B.size()+C.size()==N){
    if(A.size()==0||B.size()==0||C.size()==0) return false;
    else return (sum(A) == sum(B) && sum(B) == sum(C));
  }
  bool f1, f2, f3;
  A.push_back(E[now]); f1 = dfs(E, A, B, C, now+1); A.pop_back();
  B.push_back(E[now]); f2 = dfs(E, A, B, C, now+1); B.pop_back();
  C.push_back(E[now]); f3 = dfs(E, A, B, C, now+1); C.pop_back();
  return (f1||f2||f3);
}

signed main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  cin >> N;
  vector<ll> E(N);
  rep1(i, N) cin >> E[i];
  vector<ll> A, B, C;
  bool flag = dfs(E, A, B, C, 0);
  cout << (flag?"Yes":"No") << endl;
}
0