結果
| 問題 |
No.1148 土偶Ⅲ
|
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-08-06 17:48:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 1,192 bytes |
| コンパイル時間 | 917 ms |
| コンパイル使用メモリ | 98,032 KB |
| 実行使用メモリ | 5,760 KB |
| 最終ジャッジ日時 | 2024-09-21 14:48:13 |
| 合計ジャッジ時間 | 3,100 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1148.cc: No.1148 土偶Ⅲ - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
typedef long long ll;
/* global variables */
int as[MAX_N], uas[MAX_N], bs[MAX_N];
ll ass[MAX_N + 1];
bool used[MAX_N];
/* subroutines */
/* main */
int main() {
int n, w;
scanf("%d%d", &n, &w);
for (int i = 0; i < n; i++) {
scanf("%d", as + i);
ass[i + 1] = ass[i] + as[i];
uas[i] = as[i];
}
sort(uas, uas + n);
int m = unique(uas, uas + n) - uas;
for (int i = 0; i < n; i++)
bs[i] = lower_bound(uas, uas + m, as[i]) - uas;
int maxl = 0;
for (int i = 0, j = 0; i < n; i++) {
while (j < n && ! used[bs[j]] && ass[j + 1] - ass[i] <= w)
used[bs[j++]] = true;
int l = j - i;
if (maxl < l) maxl = l;
used[bs[i]] = false;
}
printf("%d\n", maxl);
return 0;
}
tnakao0123