Problem:
F： 掛け算は楽しい - Multiplication Is Interesting -
物語
男子高生の難波列くんは、彼女の誕生日に数列をプレゼントしようと考えている。彼女は掛け算が大好きな女の子なので、難波くんは彼女にできるだけ多くの掛け算を楽しんてもらえるような数列をプレゼントしたいと思っている。しかし、計算結果が
2^{20}
を超える値になると彼女の機嫌が途端に悪くなってしまう（通常の人類は
2^{20}
という膨大な数を計算できないため、これでも彼女は随分と寛大な人であると言える）。彼女の機嫌を損なわないように、できるだけ多くの掛け算を楽しんでもらえる数列を難波くんが作ったので、あなたの仕事はその数列が彼女を十分に楽しませられるか検証するプログラムを作ることである。つまり、あなたの仕事は数列の連続する部分列の中で、部分列の総積が
K
を超えない最長の部分列の長さを答えるプログラムを作ることである。
問題
長さ
N
の非負実数列
S = s_1, s_2, ..., s_N
と 非負実数
K
がある。 あなたの仕事は、以下の条件を満たす
S
の連続する部分列のうち、次の条件を満たす最長の部分列の長さを求めることである。このとき、部分列の長さは
1
以上でなければならない。
S
の連続する部分列 $T = s_\ell, \ldots, s_r$ について $\prod_{i = \ell, \ldots, r} s_i \leq$
K
を満たす。
もし条件を満たす部分列が一つも存在しないときは、
0
を出力せよ。
入力形式
入力は次の形式で与えられる．
N
K
s_1
s_2
$\dots$
s_N
1
行目には数列の長さ
N
と 部分列の総積の上限
K
が与えられる。続く
N
行のうち、
i
行目では非負実数列
S
の
i
番目の実数
s_i
が与えられる。
制約
1 \leq N \leq 100,000
0 \leq s_i \leq 2.00
0 \leq K \leq 1,048,576
N
は整数、
K
と
s_i
は小数点第
3
位以下を含まない実数である
出力形式
S
の部分列の総積が
K
を超えない最長の部分列の長さを
1
行に出力せよ。
入力例1
6 2.01
1.10 
1.44
0.91
2.00
1.12
1.55
出力例1
3
入力例2
8 12.22
2.00
2.00
2.00
1.91
2.00
2.00
2.00
0.01
出力例2
8

Submitted solutions:

code_snippet: // AOJ #2843 Multiplication Is Interesting
// 2025.5.28

#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 1e9;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int Cin() {
	int n = 0; int c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

double Cinf() {
	double x, y;
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	if (c == '.') {
		x = 0;
		y = 1, c = gc();
		do y *= 0.1, x += y * (c & 0xf), c = gc(); while (c >= '0');
		x += n;
	} else x = n;
	return x;
}

void Cout(int n) {
	char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		int i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

struct BIT {
    int n;
    vector<int> t;
    BIT(int _n): n(_n), t(n+1, INF) {}
    void upd(int i, int v) {
        for (; i <= n; i += i & -i) if (t[i] > v) t[i] = v;
    }
    int qry(int i) const {
        int r = INF;
        for (; i > 0; i -= i & -i) if (t[i] < r) r = t[i];
        return r;
    }
};

int main(){
    int N = Cin();
    double K = Cinf();

    vector<double> s(N+1);
    bool has0 = false;
    for(int i = 1; i <= N; i++){
        s[i] = Cinf();
        if (s[i] < EPS) has0 = true;
    }

    if (has0) { Cout(N); return 0; }
    if (K < EPS) { Cout(0); return 0; }

    vector<double> p(N+1);
    p[0] = 0.0L;
    for(int i = 1; i <= N; i++) p[i] = p[i-1] + log(s[i]);
    double logK = log(K);

    vector<double> xs = p;
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    int M = xs.size();

    auto get_idx = [&](double v){
        return int(lower_bound(xs.begin(), xs.end(), v) - xs.begin()) + 1;
    };

    BIT bit(M);
    bit.upd(M - get_idx(p[0]) + 1, 0);

    int ans = 0;
    for(int r = 1; r <= N; r++){
        double thr = p[r] - logK;
        auto it = lower_bound(xs.begin(), xs.end(), thr);
        if(it != xs.end()){
            int idx_thr = int(it - xs.begin()) + 1;
            int rev = M - idx_thr + 1;
            int i0 = bit.qry(rev);
            if (i0 < INF) ans = max(ans, r - i0);
        }
        int idx_r = get_idx(p[r]);
        bit.upd(M - idx_r + 1, r);
    }
    Cout(ans);
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6248
final_rank: 1

code_snippet: // AOJ #2843 Multiplication Is Interesting
// 2025.5.28

#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld EPS = 1e-9;
const int INF = 1e9;

struct BIT {
    int n;
    vector<int> t;
    BIT(int _n): n(_n), t(n+1, INF) {}
    void upd(int i, int v) {
        for (; i <= n; i += i & -i) if (t[i] > v) t[i] = v;
    }
    int qry(int i) const {
        int r = INF;
        for (; i > 0; i -= i & -i) if (t[i] < r) r = t[i];
        return r;
    }
};

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int N;
    ld K;
    cin >> N >> K;

    vector<ld> s(N+1);
    bool has0 = false;
    for(int i = 1; i <= N; i++){
        cin >> s[i];
        if (fabsl(s[i]) < EPS) has0 = true;
    }

    if (has0) {
        cout << N << endl;
        return 0;
    }
    if (fabsl(K) < EPS) {
        cout << 0 << endl;
        return 0;
    }

    vector<ld> p(N+1);
    p[0] = 0.0L;
    for(int i = 1; i <= N; i++) p[i] = p[i-1] + logl(s[i]);
    ld logK = logl(K);

    vector<ld> xs = p;
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    int M = xs.size();

    auto get_idx = [&](ld v){
        return int(lower_bound(xs.begin(), xs.end(), v) - xs.begin()) + 1;
    };

    BIT bit(M);
    {
        int i0 = get_idx(p[0]);
        bit.upd(M - i0 + 1, 0);
    }

    int ans = 0;
    for(int r = 1; r <= N; r++){
        ld thr = p[r] - logK;
        auto it = lower_bound(xs.begin(), xs.end(), thr);
        if(it != xs.end()){
            int idx_thr = int(it - xs.begin()) + 1;
            int rev = M - idx_thr + 1;
            int i0 = bit.qry(rev);
            if (i0 < INF) ans = max(ans, r - i0);
        }
        int idx_r = get_idx(p[r]);
        bit.upd(M - idx_r + 1, r);
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 8228
final_rank: 5

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int N;
double K,S[SIZE],ruiseki[SIZE],table[SIZE];

int main(){

	scanf("%d %lf",&N,&K);

	ruiseki[0] = 0.0;

	for(int i = 1; i <= N; i++){

		scanf("%lf",&S[i]);
		if(S[i] == 0.0){
			printf("%d\n",N);
			return 0;
		}
		S[i] = log(S[i]);
		ruiseki[i] = S[i];
		ruiseki[i] += ruiseki[i-1];
	}
	if(K == 0){

		printf("0\n");
		return 0;
	}

	K = log(K);

	table[N] = ruiseki[N];

	for(int i = N-1; i >= 1; i--){

		table[i] = min(ruiseki[i],table[i+1]);
	}

	int ans = 0;
	int left,right,mid,R;

	for(int i = 1; i <= N; i++){

		left = i,right = N,mid = (left+right)/2;
		R = -1;

		while(left <= right){

			if(table[mid]-ruiseki[i-1] <= K){

				R = mid;
				left = mid+1;
			}else{

				right = mid-1;
			}
			mid = (left+right)/2;
		}

		if(R == -1)continue;
		ans = max(ans,R-i+1);
	}

	printf("%d\n",ans);

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 5820
final_rank: 2

code_snippet: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {

    ll n;
    cin >> n;
    double k;
    cin >> k;
    vector<double> s(n);
    rep(i, n) cin >> s[i];

    // 0がある
    bool is_zero = false;
    // すべてk以上
    bool over_k = true;
    rep(i, n) {
        if (s[i] == 0.0) is_zero = true;
        if (s[i] <= k) over_k = false;
    }

    if (is_zero) {
        cout << n << endl;
        return 0;
    }
    if (over_k && k >= 1.0) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n) s[i] = log(s[i]);
    k = log(k);

    vector<double> sum(n + 1, 0.0);
    rep(i, n) {
        sum[i + 1] = sum[i] + s[i];
    }

    auto copy = sum;

    for (int i = n - 1; i >= 0; --i) {
        chmin(copy[i], copy[i + 1]);
    }

    int ans = 0;
    rep(i, n) {
        chmax(ans, (int)(upper_bound(allof(copy), sum[i] + k) - copy.begin() - i - 1));
    }

    cout << ans << endl;

    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 5712
final_rank: 3

code_snippet: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {

    ll n;
    cin >> n;
    double k;
    cin >> k;
    vector<double> s(n);
    rep(i, n) cin >> s[i];

    // 0がある
    bool is_zero = false;
    // すべてk以上
    bool over_k = true;
    rep(i, n) {
        if (s[i] == 0.0) is_zero = true;
        if (s[i] < k) over_k = false;
    }

    if (is_zero) {
        cout << n << endl;
        return 0;
    }
    if (over_k && k >= 1.0) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n) s[i] = log(s[i]);
    k = log(k);

    vector<double> sum(n + 1, 0.0);
    rep(i, n) {
        sum[i + 1] = sum[i] + s[i];
    }

    auto copy = sum;

    for (int i = n - 1; i >= 0; --i) {
        chmin(copy[i], copy[i + 1]);
    }

    int ans = 0;
    rep(i, n) {
        chmax(ans, (int)(upper_bound(allof(copy), sum[i] + k) - copy.begin() - i - 1));
    }

    cout << ans << endl;

    return 0;
}
accuracy: 0.9692307692307692
time_ms: 30
memory_kb: 5680
final_rank: 8

code_snippet: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {

    ll n;
    cin >> n;
    double k;
    cin >> k;
    vector<double> s(n);
    rep(i, n) cin >> s[i];

    // 0がある
    bool is_zero = false;
    // すべてk以上
    bool over_k = true;
    rep(i, n) {
        if (s[i] == 0.0) is_zero = true;
        if (s[i] < k) over_k = false;
    }

    if (is_zero) {
        cout << n << endl;
        return 0;
    }
    if (over_k) {
        cout << 0 << endl;
        return 0;
    }

    rep(i, n) s[i] = log(s[i]);
    k = log(k);

    vector<double> sum(n + 1, 0.0);
    rep(i, n) {
        sum[i + 1] = sum[i] + s[i];
    }

    auto copy = sum;

    for (int i = n - 1; i >= 0; --i) {
        chmin(copy[i], copy[i + 1]);
    }

    int ans = 0;
    rep(i, n) {
        chmax(ans, (int)(upper_bound(allof(copy), sum[i] + k) - copy.begin() - i - 1));
    }

    cout << ans << endl;

    return 0;
}
accuracy: 0.6
time_ms: 30
memory_kb: 5684
final_rank: 12

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<double,ll> mp;
ll inf =  1e9;
double EPS = 1e-12;

int main(){
 ll n;
 double k;
 cin>>n>>k;
 vector<double> s(n),ls(n+1,0);
 for(ll i=0;i<n;i++)cin>>s[i];
 for(ll i=0;i<n;i++){
  if( s[i] == 0.0 ){
   cout<<n<<endl;
   return 0;
  }
 }

 for(ll i=0;i<n;i++)ls[i+1] = log( s[i] );
 for(ll i=1;i<=n;i++)ls[i] += ls[i-1];
 ll ans = 0;
 ll st=0;
 double lk = log(k);
 
 vector<mp> lss(n+1);
 for(ll i=0;i<=n;i++){
  lss[i] = mp( ls[i] , i );
 }
 sort( lss.begin() , lss.end() );
 for(ll i=n;i>=1;i--){
  lss[i-1].second = min( lss[i-1].second , lss[i].second );
 }
 
 //尺とり
 /*for(ll i=1;i<=n;i++){
  while( ls[i]-ls[st] > lk + EPS ) st++;
  ans = max( ans , i-st );
 }*/
 for(ll i=1;i<=n;i++){
  auto it = lower_bound( lss.begin() , lss.end() , mp( ls[i] - lk , 0 ) ); 
  if( it == lss.end() ) continue;
  ans = max( ans , i - it->second );
 }

 cout<<ans<<endl;


    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 6404
final_rank: 4

code_snippet: #include <iostream>
#include <cmath>
#include <functional>
#include <vector>
using namespace std;

template <typename T>
struct SegmentTree{
private:
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
public:
  SegmentTree(){};
  SegmentTree(F f,T ti) : f(f),ti(ti) {}
  void build(int n_){
    n = n_;
    dat.assign(2*n,ti);
  }
  void build(const vector<T> &v){
    int n_ = v.size();
    build(n_);
    for(int i = 0; i < n; ++i) dat[n+i]=v[i];
    for(int i = n-1; i >= 0; --i)
      dat[i]=f(dat[2*i+0],dat[2*i+1]);
  }
  void set_val(int k,T x){
    dat[k+=n] = x;
    while(k > 0){
      k = k/2;
      dat[k]=f(dat[2*k+0],dat[2*k+1]);
    }
  }
  T query(int a,int b){
    T vl = ti, vr = ti;
    for(int l = a+n, r = b+n; l < r; l >>= 1, r >>= 1){
      if(l&1) vl = f(vl,dat[l++]);
      if(r&1) vr = f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};


int main(){
  using T = double;
  function<T(T,T)> f = [](T a, T b){
                         return min(a,b);
                       };
  T ti = 1e9;
  SegmentTree<T> st(f,ti);
  int n;
  double k;
  cin >> n >> k;
  vector<double> S(n);
  for(int i = 0; i < n; ++i) cin >> S[i];
  for(int i = 0; i < n; ++i){
    if(S[i] < 1e-3){
      cout << n << endl;
      return 0;
    }
  }
  double lk = log(k);
  vector<double> L(n+1);
  for(int i = 0; i < n; ++i)
    L[i+1] = log(S[i]);
  for(int i = 0; i < n; ++i)
    L[i+1] += L[i];
  st.build(L);
  int ans = 0;
  for(int i = 0; i < n; ++i){
    int ok = i, ng = n+2;
    while(ng-ok > 1){
      int m = (ok+ng)/2;
      double mi = st.query(m,n+1);
      if(mi-L[i] > lk) ng = m;
      else ok = m;
    }
    ans = max(ans,ok-i);
  }
  cout << ans << endl;
}
accuracy: 1
time_ms: 130
memory_kb: 6476
final_rank: 7

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

class XorShift {
	unsigned int x, y, z, w, t;
public:
	XorShift() {
		x = 133553533;
		y = 314867339;
		z = 664298413;
		w = 999999937;
		t = 0;
	}
	unsigned int rand() {
		t = x ^ (x << 11);
		x = y;
		y = z;
		z = w;
		w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
		return w & 0x7fffffff;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	XorShift xs;
	cin>>N>>MX;
	if(abs(MX)<EPS){
		vector<long double>v(N);
		for(auto &i:v)cin>>i;
		vector<int>sum(N);
		for(int i=0;i<N;i++){
			sum[i]=abs(v[i])<EPS;
		}
		for(int i=1;i<N;i++)sum[i]+=sum[i-1];
		cout<<*max_element(sum.begin(),sum.end())<<endl;
		return 0;
	}
	MX=log(MX);
//	for(int loop=0;loop<100;loop++){
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		v[i]=xs.rand()%200;
		v[i]++;
		//cout<<v[i]<<" ";
		v[i]/=100;
		cin>>v[i];
		if(abs(v[i])<EPS){
			cout<<N<<endl;
			return 0;
		}
		v[i]=log(v[i]);
	}
	//cout<<endl;
	int ret=0;
	for(int i=1;i<=N;i++){
		long double box=0;
		for(int j=i;j<=N;j++){
			box+=v[j];
			if(box-EPS<MX){
				ret=max(ret,j-i+1);
			}
		}
	}
	//cout<<ret<<" ";
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	long long int ans=0;
	for(long long int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			//cout<<mp[{v[i],i}]<<" "<<i<<endl;
			ans=max(ans,i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		long long int num=sg.RMQ(index,cnt);
		//cout<<num<<endl;
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	//if(ret!=ans){
	//	cout<<ret<<" "<<ans<<endl;
	//}
	//}
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18172
final_rank: 17

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	cin>>N>>MX;
	MX=log(MX);
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>v[i];
		if(abs(v[i])<EPS){
			cout<<N<<endl;
			return 0;
		}
		v[i]=log(v[i]);
	}
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	long long int ans=0;
	for(long long int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			//cout<<mp[{v[i],i}]<<" "<<i<<endl;
			ans=max(ans,i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		long long int num=sg.RMQ(index,cnt);
		//cout<<num<<endl;
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18124
final_rank: 15

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-6;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	cin>>N>>MX;
	MX=log(MX);
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>v[i];
		if(abs(v[i])<EPS){
			cout<<N<<endl;
			return 0;
		}
		v[i]=log(v[i]);
	}
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	long long int ans=0;
	for(int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			//cout<<mp[{v[i],i}]<<" "<<i<<endl;
			ans=max(ans,(long long int)i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		long long int num=sg.RMQ(index,cnt);
		//cout<<num<<endl;
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18120
final_rank: 14

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-6;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	cin>>N>>MX;
	MX=log(MX);
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>v[i];
		v[i]=log(v[i]);
	}
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	int ans=0;
	for(int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			ans=max(ans,i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		int num=sg.RMQ(index,cnt);
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18124
final_rank: 15

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-10;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	cin>>N>>MX;
	MX=log(MX);
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>v[i];
		v[i]=log(v[i]);
	}
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	int ans=0;
	for(int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			ans=max(ans,i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		int num=sg.RMQ(index,cnt);
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18104
final_rank: 13

code_snippet: #include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		n++;
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		is_min = min;
		if (min) {
			v.resize(num, MOD*MOD);
		}
		else v.resize(num, -MOD*MOD);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long double MX;
	cin>>N>>MX;
	MX=log(MX);
	vector<long double>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>v[i];
		v[i]=log(v[i]);
	}
	v[0]=1000;
	for(int i=1;i<=N;i++)v[i]+=v[i-1];
	map<pair<long double,int>,int>mp;
	for(int i=0;i<=N;i++){
		mp[{v[i],i}]=0;
	}
	int cnt=0;
	for(auto &i:mp)i.second=cnt++;
	Segment_Tree sg(cnt,true);
	sg.Insert(mp[{v[0],0}],0,true);
	int ans=0;
	for(int i=1;i<=N;i++){
		long double box=v[i]-MX;
		auto it = mp.lower_bound({box-EPS,0});
		if(it==mp.end()){
			ans=max(ans,i);
			sg.Insert(mp[{v[i],i}],i,true);
			continue;
		}
		int index=it->second;
		int num=sg.RMQ(index,cnt);
		ans=max(ans,i-num);
		sg.Insert(mp[{v[i],i}],i,true);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
accuracy: 0.6
time_ms: 70
memory_kb: 18172
final_rank: 17

code_snippet: #include <bits/stdc++.h>
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
double k;
double s[100001];
long double sum[100001];

class segtree{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree(){
		memset(dp,-1,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		if(dp[k]==-1)dp[k]=v;
		dp[k]=min(v,dp[k]);
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return N;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

segtree seg;

int main(void){
	scanf("%d%lf",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lf",&s[i]);
	}
	if(k<EPS){
		int len=0;
		int res=0;
		for(int i=0;i<n;i++){
			if(s[i]<EPS)len++;
			else len=0;
			if(len>0)res=n;
		}
		printf("%d\n",res);
		return 0;
	}
	for(int i=0;i<n;i++){
		if(s[i]<EPS){
			printf("%d\n",n);
			return 0;
		}
	}
	vector<long double> vec;
	vec.push_back(0.0);
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=logl(s[i]);
		vec.push_back(sum[i+1]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<vec.size();i++){
		seg.update(i,1<<18);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int v=lower_bound(vec.begin(),vec.end(),sum[i])-vec.begin();
		seg.update(v,i);
		v=lower_bound(vec.begin(),vec.end(),sum[i+1]-logl(k))-vec.begin();
		ans=max(ans,i+1-seg.query(v,vec.size()));
	}
	printf("%d\n",ans);
	return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 9348
final_rank: 6

code_snippet: #include <bits/stdc++.h>
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
double k;
double s[100001];
long double sum[100001];

class segtree{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return N;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

segtree seg;

int main(void){
	scanf("%d%lf",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lf",&s[i]);
	}
	if(k<EPS){
		int len=0;
		int res=0;
		for(int i=0;i<n;i++){
			if(s[i]<EPS)len++;
			else len=0;
			if(len>0)res=n;
		}
		printf("%d\n",res);
		return 0;
	}
	for(int i=0;i<n;i++){
		if(s[i]<EPS){
			printf("%d\n",n);
			return 0;
		}
	}
	vector<long double> vec;
	vec.push_back(0.0);
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=logl(s[i]);
		vec.push_back(sum[i+1]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<vec.size();i++){
		seg.update(i,1<<18);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int v=lower_bound(vec.begin(),vec.end(),sum[i])-vec.begin();
		seg.update(v,i);
		v=lower_bound(vec.begin(),vec.end(),sum[i+1]-logl(k))-vec.begin();
		ans=max(ans,i+1-seg.query(v,vec.size()));
	}
	printf("%d\n",ans);
	return 0;
}
accuracy: 0.6615384615384615
time_ms: 50
memory_kb: 9348
final_rank: 11

code_snippet: #include <bits/stdc++.h>
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
double k;
double s[100001];
double sum[100001];

class segtree{
public:
	static const int N=1<<17;
	int dp[1<<18];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return N;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

segtree seg;

int main(void){
	scanf("%d%lf",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lf",&s[i]);
	}
	if(k<EPS){
		int len=0;
		int res=0;
		for(int i=0;i<n;i++){
			if(s[i]<EPS)len++;
			else len=0;
			if(len>0)res=n;
		}
		printf("%d\n",res);
		return 0;
	}
	for(int i=0;i<n;i++){
		if(s[i]<EPS){
			printf("%d\n",n);
			return 0;
		}
	}
	vector<double> vec;
	vec.push_back(0.0);
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=log(s[i]);
		vec.push_back(sum[i+1]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<vec.size();i++){
		seg.update(i,1<<18);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int v=lower_bound(vec.begin(),vec.end(),sum[i])-vec.begin();
		seg.update(v,i);
		v=lower_bound(vec.begin(),vec.end(),sum[i+1]-log(k))-vec.begin();
		ans=max(ans,i+1-seg.query(v,vec.size()));
	}
	printf("%d\n",ans);
	return 0;
}
accuracy: 0.6615384615384615
time_ms: 50
memory_kb: 6896
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
double k;
double s[100001];
double sum[100001];

class segtree{
public:
	static const int N=1<<17;
	int dp[1<<18];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return N;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

segtree seg;

int main(void){
	scanf("%d%lf",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lf",&s[i]);
	}
	if(k<EPS){
		int len=0;
		int res=0;
		for(int i=0;i<n;i++){
			if(s[i]<EPS)len++;
			else len=0;
			if(len>0)res=n;
		}
		printf("%d\n",res);
		return 0;
	}
	for(int i=0;i<n;i++){
		if(s[i]<EPS){
			printf("%d\n",n);
			return 0;
		}
	}
	vector<double> vec;
	vec.push_back(0.0);
	for(int i=0;i<n;i++){
		sum[i+1]+=sum[i];
		sum[i+1]+=log(s[i]);
		vec.push_back(sum[i+1]);
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		seg.update(i,1<<18);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int v=lower_bound(vec.begin(),vec.end(),sum[i])-vec.begin();
		seg.update(v,i);
		v=lower_bound(vec.begin(),vec.end(),sum[i+1]-log(k))-vec.begin();
		ans=max(ans,i+1-seg.query(v,n+1));
	}
	printf("%d\n",ans);
	return 0;
}
accuracy: 0.6615384615384615
time_ms: 50
memory_kb: 6896
final_rank: 9