結果
| 問題 | No.1148 土偶Ⅲ |
| ユーザー |
|
| 提出日時 | 2020-09-09 18:18:45 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 402 bytes |
| 記録 | |
| コンパイル時間 | 933 ms |
| コンパイル使用メモリ | 72,704 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 00:03:12 |
| 合計ジャッジ時間 | 2,651 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
#include<set>
using namespace std;
int N,W;
int A[1<<17];
main()
{
cin>>N>>W;
int ans=0;
for(int i=0;i<N;i++)cin>>A[i];
long S=0;
set<int>s;
int r=0;
for(int i=0;i<N;i++)
{
while(s.find(A[i])!=s.end())
{
s.erase(A[r]);
S-=A[r++];
}
S+=A[i];
s.insert(A[i]);
while(S>W)
{
s.erase(A[r]);
S-=A[r++];
}
if(ans<i-r+1)ans=i-r+1;
}
cout<<ans<<endl;
}