結果

問題 No.2500 Products in a Range
ユーザー Carpenters-Cat
提出日時 2023-10-13 22:15:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,096 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 193,000 KB
最終ジャッジ日時 2025-02-17 07:21:11
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
	int N;
	ll L, R;
	cin >> N >> L >> R;
	ll A[5050];
	for (int i = 0; i < N; i ++) cin >> A[i];
	int ans = 1;
	for (int l = 0; l < N - 1; l ++) {
		ll mn[] = {-1, -1}, pl[] = {-1, -1};
		for (int r = l; r <= N; r ++) {
			if (r == N) {
				ans = max(ans, N - l);
				continue;
			}
			bool ok = true;
			if (A[r] == 0) {
				if (L * R > 0) {
					ok = false;
				}
			} else if (A[r] < 0) {
				ll a = A[r] * -1;
				if (a > mn[0]) {
					mn[1] = mn[0];
					mn[0] = a;
				} else if (a > mn[1]) {
					mn[1] = a;
				}
			} else {
				ll a = A[r];
				if (a > pl[0]) {
					pl[1] = pl[0];
					pl[0] = a;
				} else if (a > mn[1]) {
					mn[1] = a;
				}
			}
			if (pl[0] > 0 && mn[0] > 0) {
				ll x = pl[0] * mn[0] * -1;
				ok = ok && (L <= x) && (x <= R);
			}
			if (pl[1] > 0) {
				ll x = pl[0] * pl[1];
				ok = ok && (L <= x && x <= R);
			}
			if (mn[1] > 0) {
				ll x = mn[0] * mn[1];
				ok = ok && (L <= x && x <= R);
			}
			if (!ok) {
				ans = max(ans, r - l);
			}
		}
	}
	cout << ans << endl;
}
0