結果

問題 No.2500 Products in a Range
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-10-13 22:15:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,096 bytes
コンパイル時間 2,735 ms
コンパイル使用メモリ 199,528 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-13 22:15:57
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 23 ms
4,348 KB
testcase_34 AC 66 ms
4,348 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 2 ms
4,348 KB
testcase_41 WA -
testcase_42 AC 1 ms
4,352 KB
testcase_43 WA -
testcase_44 AC 6 ms
4,348 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 122 ms
4,356 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

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