結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2020-08-06 04:25:49 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 493 bytes |
| 記録 | |
| コンパイル時間 | 2,138 ms |
| コンパイル使用メモリ | 218,000 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-06-12 01:48:37 |
| 合計ジャッジ時間 | 2,910 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 1 |
ソースコード
#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;
}