結果

問題 No.2500 Products in a Range
ユーザー achapiachapi
提出日時 2023-10-13 21:26:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,922 bytes
コンパイル時間 2,206 ms
コンパイル使用メモリ 204,624 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 21:26:56
合計ジャッジ時間 6,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 102 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 74 ms
4,352 KB
testcase_11 AC 95 ms
4,352 KB
testcase_12 AC 36 ms
4,352 KB
testcase_13 AC 4 ms
4,352 KB
testcase_14 AC 118 ms
4,352 KB
testcase_15 AC 7 ms
4,352 KB
testcase_16 AC 84 ms
4,348 KB
testcase_17 AC 39 ms
4,348 KB
testcase_18 AC 43 ms
4,352 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 140 ms
4,348 KB
testcase_23 AC 144 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 140 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 31 ms
4,348 KB
testcase_34 AC 80 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 1 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 1 ms
4,352 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,352 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 1 ms
4,352 KB
testcase_44 AC 11 ms
4,352 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 26 ms
4,352 KB
testcase_47 AC 140 ms
4,348 KB
testcase_48 AC 2 ms
4,352 KB
testcase_49 WA -
testcase_50 AC 40 ms
4,352 KB
testcase_51 AC 47 ms
4,348 KB
testcase_52 AC 96 ms
4,352 KB
testcase_53 AC 13 ms
4,352 KB
testcase_54 AC 2 ms
4,356 KB
testcase_55 AC 35 ms
4,352 KB
testcase_56 AC 41 ms
4,348 KB
testcase_57 AC 68 ms
4,348 KB
testcase_58 AC 13 ms
4,348 KB
testcase_59 AC 104 ms
4,348 KB
testcase_60 AC 5 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, l, r;
	cin >> n >> l >> r;
	vector<int> A(n);
	for (int i = 0; i < n; i++){
		cin >> A[i];
	}
	int ans = 0;
	sort(A.begin(), A.end());
	for (int i = 0; i < n; i++){
		vector<int> p, m;
		for (int j = i; j < n; j++){
			if (A[j] > 0){
				p.push_back(A[j]);
			} else {
				m.push_back(A[j]);
			}
			bool ok = true;
			if ((int) p.size() >= 2){
				long long c = (long long) p[p.size() - 1] * p[p.size() - 2];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 2){
				long long c = (long long) p[p.size() - 1] * p[0];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 2){
				long long c = (long long) p[0] * p[1];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) m.size() >= 2){
				long long c = (long long) m[0] * m[1];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) m.size() >= 2){
				long long c = (long long) m[m.size() - 1] * m[m.size() - 2];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) m.size() >= 2){
				long long c = (long long) m[m.size() - 1] * m[0];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 1 and (int) m.size() >= 1){
				long long c = (long long) p[p.size() - 1] * m[0] < l;
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 1 and (int) m.size() >= 1){
				long long c = (long long) p[p.size() - 1] * m[m.size() - 1];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 1 and (int) m.size() >= 1){
				long long c = (long long) p[0] * m[m.size() - 1];
				if (c < l or r < c){
					ok = false;
				}
			}
			if ((int) p.size() >= 1 and (int) m.size() >= 1){
				long long c = (long long) p[0] * m[0];
				if (c < l or r < c){
					ok = false;
				}
			}
			if (ok){
				ans = max(ans, j - i + 1);
			}
		}
	}
	cout << ans << endl;
}
0