結果
問題 | No.1148 土偶Ⅲ |
ユーザー | iqueue02 |
提出日時 | 2020-08-14 00:01:56 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 201,076 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2024-04-18 01:55:32 |
合計ジャッジ時間 | 3,456 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 16 ms
5,376 KB |
testcase_06 | AC | 58 ms
5,400 KB |
testcase_07 | AC | 43 ms
5,468 KB |
testcase_08 | AC | 53 ms
5,436 KB |
testcase_09 | AC | 47 ms
5,376 KB |
testcase_10 | AC | 16 ms
5,376 KB |
testcase_11 | AC | 61 ms
6,272 KB |
testcase_12 | AC | 5 ms
5,376 KB |
testcase_13 | AC | 6 ms
5,376 KB |
testcase_14 | AC | 5 ms
5,376 KB |
testcase_15 | AC | 41 ms
5,620 KB |
testcase_16 | AC | 15 ms
5,376 KB |
testcase_17 | AC | 40 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 17 ms
5,376 KB |
testcase_20 | AC | 39 ms
5,376 KB |
testcase_21 | AC | 27 ms
5,376 KB |
testcase_22 | AC | 5 ms
5,376 KB |
testcase_23 | AC | 7 ms
5,376 KB |
testcase_24 | AC | 9 ms
5,376 KB |
testcase_25 | AC | 10 ms
5,376 KB |
testcase_26 | AC | 31 ms
5,376 KB |
testcase_27 | AC | 6 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; constexpr int INF = 1e9; int main() { int n, w; cin >> n >> w; vector<int> a(n); rep(i,n) cin >> a[i]; set<int> st; int cur = 0; int r = 0; int res = 0; for (int l = 0; l < n; l++) { while (r < n && !st.count(a[r]) && cur + a[r] <= w) { cur += a[r]; st.insert(a[r]); r++; } res = max(res, r - l); cur -= a[l]; st.erase(a[l]); } cout << res << endl; return 0; }