結果

問題 No.944 煎っぞ!
ユーザー cotton_fn_cotton_fn_
提出日時 2020-02-02 15:25:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 3,000 ms
コード長 1,206 bytes
コンパイル時間 1,325 ms
コンパイル使用メモリ 123,928 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 00:53:51
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }

int n;
vector<int> a;

int f(int x) {
    int c = 0;
    auto it = begin(a);
    while (it != end(a) - 1) {
        auto it_next = lower_bound(it, end(a), (c + 1) * x);
        if (it_next == end(a) || *it_next != (c + 1) * x) {
            return -1;
        }
        it = it_next;
        c++;
    }
    return c;
}

int main() {
    cin >> n;
    a.resize(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
        if (i > 0) a[i] += a[i - 1];
    }
    int ans = 1;
    for (int x = 1; x * x <= sum; ++x) {
        if (sum % x == 0) {
            ans = max(ans, f(x));
            ans = max(ans, f(sum / x));
        }
    }
    cout << ans << endl;
    return 0;
}
0