結果

問題 No.944 煎っぞ!
ユーザー jxkokojxkoko
提出日時 2019-12-07 14:43:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 1,355 ms
コンパイル使用メモリ 146,796 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 18:23:33
合計ジャッジ時間 3,095 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 17 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 17 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 17 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 32 ms
4,380 KB
testcase_21 AC 32 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 15 ms
4,380 KB
testcase_32 AC 16 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const int MAX = 1000000000;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<int> d;
    for (int i = 1; i <= sum; i++) {
        if (sum % i == 0) d.push_back(i);
    }
    for(auto x : d){
        int s = 0;
        bool f = true;
        for (int i = 0; i < N; i++) {
            if (s > x){
                f = false; break;
            }
            else if(s==x){
                s == 0;
            }
            else{
                s += a[i];
            }
        }
        if (f && s == x) { 
            cout << sum / x << endl;
            return 0;
        }
    }
}
0