結果

問題 No.1148 土偶Ⅲ
ユーザー furafura
提出日時 2020-08-06 04:25:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 493 bytes
コンパイル時間 2,164 ms
コンパイル使用メモリ 209,520 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2023-10-19 05:44:01
合計ジャッジ時間 4,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 AC 23 ms
5,240 KB
testcase_06 AC 75 ms
7,716 KB
testcase_07 AC 45 ms
6,412 KB
testcase_08 AC 63 ms
7,248 KB
testcase_09 AC 61 ms
7,168 KB
testcase_10 AC 25 ms
5,392 KB
testcase_11 AC 64 ms
7,176 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 40 ms
6,168 KB
testcase_16 AC 15 ms
4,792 KB
testcase_17 AC 73 ms
7,600 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 26 ms
5,344 KB
testcase_20 AC 35 ms
5,808 KB
testcase_21 AC 26 ms
5,408 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 5 ms
4,348 KB
testcase_24 AC 7 ms
4,348 KB
testcase_25 AC 7 ms
4,348 KB
testcase_26 AC 23 ms
4,348 KB
testcase_27 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n,w; scanf("%d%d",&n,&w);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int ans=0,dup=0;
	lint sum=0;
	map<int,int> f;
	for(int l=0,r=0;l<n;){
		while(r<n && sum<=w && dup==0){
			sum+=a[r];
			++f[a[r]];
			if(f[a[r]]==2) dup++;
			r++;
		}

		ans=max(ans,r-l-1);

		sum-=a[l];
		--f[a[l]];
		if(f[a[l]]==1) dup--;
		l++;
	}
	printf("%d\n",ans);

	return 0;
}
0