結果

問題 No.944 煎っぞ!
ユーザー YamaKasaYamaKasa
提出日時 2019-12-24 00:26:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 3,000 ms
コード長 856 bytes
コンパイル時間 1,574 ms
コンパイル使用メモリ 169,188 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 09:07:30
合計ジャッジ時間 3,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,348 KB
testcase_01 AC 22 ms
4,348 KB
testcase_02 AC 21 ms
4,348 KB
testcase_03 AC 22 ms
4,348 KB
testcase_04 AC 22 ms
4,348 KB
testcase_05 AC 22 ms
4,348 KB
testcase_06 AC 22 ms
4,348 KB
testcase_07 AC 22 ms
4,348 KB
testcase_08 AC 22 ms
4,348 KB
testcase_09 AC 23 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 7 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 6 ms
4,348 KB
testcase_19 AC 7 ms
4,348 KB
testcase_20 AC 23 ms
4,348 KB
testcase_21 AC 24 ms
4,348 KB
testcase_22 AC 22 ms
4,348 KB
testcase_23 AC 22 ms
4,348 KB
testcase_24 AC 22 ms
4,348 KB
testcase_25 AC 21 ms
4,348 KB
testcase_26 AC 22 ms
4,348 KB
testcase_27 AC 22 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 25 ms
4,348 KB
testcase_31 AC 68 ms
4,348 KB
testcase_32 AC 65 ms
4,348 KB
testcase_33 AC 33 ms
4,348 KB
testcase_34 AC 33 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int a[N];
    vector<int> b(N + 1);
    b[0] = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        b[i + 1] = b[i] + a[i];
    }
    int ans = 1;
    int s = 0;
    for (int i = 0; i < N; i++) {
        int v = b[i + 1];
        s = v;
        int t = 0;
        int l = i + 2;
        int cnt = 1;
        while (l <= N) {
            auto it = lower_bound(b.begin() + l, b.end(), v + s);
            int id = it - b.begin();
            if (b[id] == v + s) {
                s = b[id];
                l = id;
                cnt++;
            } else {
                break;
            }
            if (id == N) {
                ans = max(ans, cnt);
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
0