結果

問題 No.1594 Three Classes
ユーザー ekaraageekaraage
提出日時 2021-07-09 21:37:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,027 bytes
コンパイル時間 4,164 ms
コンパイル使用メモリ 259,072 KB
実行使用メモリ 813,652 KB
最終ジャッジ日時 2023-09-14 08:02:10
合計ジャッジ時間 7,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll dp[13][15000000] = {};
int main() {
    ll N;
    cin >> N;
    vector<ll> E(N);
    ll sum = 0;
    for (ll i = 0; i < N; i++) {
        cin >> E[i];
        sum += E[i];
    }
    if (sum % 3) {
		cout << "No" << endl;
        return 0;
    }
    dp[0][0] = 1;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < 1e7 + 1;j++){
            dp[i + 1][j + E[i]] += dp[i][j];
            dp[i + 1][j] += dp[i][j];
        }
    }
    if(dp[N][sum/3]>=3){
        cout << "Yes" << endl;
    }
	else
        cout << "No" << endl;
}
0