結果
問題 |
No.1148 土偶Ⅲ
|
ユーザー |
![]() |
提出日時 | 2020-08-06 04:19:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 2,533 ms |
コンパイル使用メモリ | 200,752 KB |
最終ジャッジ日時 | 2025-01-12 15:15:09 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 5 |
ソースコード
#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; }