結果

問題 No.1148 土偶Ⅲ
ユーザー trineutrontrineutron
提出日時 2020-08-06 04:19:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 738 bytes
コンパイル時間 2,696 ms
コンパイル使用メモリ 210,536 KB
実行使用メモリ 4,968 KB
最終ジャッジ日時 2023-10-19 05:32:56
合計ジャッジ時間 4,418 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 16 ms
4,348 KB
testcase_06 AC 41 ms
4,616 KB
testcase_07 AC 28 ms
4,348 KB
testcase_08 AC 36 ms
4,352 KB
testcase_09 AC 35 ms
4,352 KB
testcase_10 AC 17 ms
4,348 KB
testcase_11 AC 35 ms
4,352 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 26 ms
4,348 KB
testcase_16 AC 11 ms
4,348 KB
testcase_17 AC 41 ms
4,616 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 18 ms
4,348 KB
testcase_20 AC 22 ms
4,348 KB
testcase_21 AC 16 ms
4,348 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, w;
    cin >> n >> w;
    vector<int64_t> a(n), s(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        s.at(i + 1) = s.at(i) + a.at(i);
    }
    int discard = 0, ans = 0;
    set<int64_t> t;
    for (int i = 0; i < n; i++) {
        if (t.find(a.at(i)) == t.end()) {
            t.insert(a.at(i));
            while (s.at(i + 1) - s.at(discard) > w) {
                t.erase(a.at(discard));
                discard++;
            }
        } else {
            while (a.at(discard) != a.at(i)) {
                discard++;
            }
            discard++;
        }
        ans = max(ans, i + 1 - discard);
    }
    cout << ans << endl;
}
0