結果
| 問題 |
No.1148 土偶Ⅲ
|
| ユーザー |
👑 |
| 提出日時 | 2021-12-23 08:27:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 2,000 ms |
| コード長 | 462 bytes |
| コンパイル時間 | 755 ms |
| コンパイル使用メモリ | 81,780 KB |
| 実行使用メモリ | 7,808 KB |
| 最終ジャッジ日時 | 2024-09-17 06:28:09 |
| 合計ジャッジ時間 | 3,179 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
long long n,w;cin>>n>>w;
vector<long long> A(n);
for(int i = 0; n > i; i++){
cin>>A[i];
}
map<int,int> X;
long long W = 0;
int eras = 0;
int ans = 0;
for(int i = 0; n > i; i++){
X[A[i]]++;
W+=A[i];
while(X[A[i]] > 1 || W > w){
X[A[eras]]--;
W-=A[eras];
eras++;
}
ans = max(ans,i-eras+1);
}
cout << ans << endl;
}