結果

問題 No.944 煎っぞ!
ユーザー YamaKasa
提出日時 2019-12-24 00:25:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 1,538 ms
コンパイル使用メモリ 169,164 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-19 05:19:48
合計ジャッジ時間 3,615 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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