結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2025-02-13 12:36:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 42 ms / 2,000 ms |
| コード長 | 690 bytes |
| 記録 | |
| コンパイル時間 | 3,707 ms |
| コンパイル使用メモリ | 281,416 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-13 12:36:35 |
| 合計ジャッジ時間 | 6,064 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) (void(0))
#endif
void run_case();
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) run_case();
return 0;
}
void run_case() {
int N, W;
cin >> N >> W;
vector<int> A(N);
for(auto&x: A) cin >> x;
set<int> st;
ll sum = 0;
int r = 0;
int ans = 0;
for(int l = 0; l < N; l++) {
while(r < N && sum + A[r] < W && st.find(A[r]) == st.end()) {
sum += A[r];
st.insert(A[r]);
r++;
}
debug(l, r);
ans = max(ans, r - l);
st.erase(A[l]);
sum -= A[l];
}
cout << ans << endl;
}