結果

問題 No.2500 Products in a Range
ユーザー kwm_tkwm_t
提出日時 2023-10-15 16:06:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,979 bytes
コンパイル時間 2,462 ms
コンパイル使用メモリ 205,364 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-15 16:06:52
合計ジャッジ時間 16,592 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 WA -
testcase_02 AC 14 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 6 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 119 ms
4,368 KB
testcase_08 AC 211 ms
4,372 KB
testcase_09 WA -
testcase_10 AC 730 ms
4,368 KB
testcase_11 AC 995 ms
4,372 KB
testcase_12 AC 329 ms
4,368 KB
testcase_13 AC 10 ms
4,372 KB
testcase_14 AC 516 ms
4,372 KB
testcase_15 AC 22 ms
4,368 KB
testcase_16 AC 8 ms
4,372 KB
testcase_17 AC 4 ms
4,368 KB
testcase_18 AC 5 ms
4,372 KB
testcase_19 AC 10 ms
4,368 KB
testcase_20 AC 11 ms
4,372 KB
testcase_21 AC 2 ms
4,372 KB
testcase_22 AC 46 ms
4,368 KB
testcase_23 AC 23 ms
4,372 KB
testcase_24 AC 35 ms
4,372 KB
testcase_25 AC 1,442 ms
4,368 KB
testcase_26 AC 1,443 ms
4,372 KB
testcase_27 AC 1,445 ms
4,368 KB
testcase_28 AC 10 ms
4,372 KB
testcase_29 AC 3 ms
4,372 KB
testcase_30 AC 2 ms
4,372 KB
testcase_31 AC 2 ms
4,372 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 291 ms
4,372 KB
testcase_34 AC 818 ms
4,368 KB
testcase_35 AC 2 ms
4,368 KB
testcase_36 AC 2 ms
4,368 KB
testcase_37 AC 1 ms
4,368 KB
testcase_38 AC 1 ms
4,368 KB
testcase_39 AC 1 ms
4,368 KB
testcase_40 AC 2 ms
4,372 KB
testcase_41 AC 2 ms
4,368 KB
testcase_42 AC 1 ms
4,372 KB
testcase_43 AC 2 ms
4,372 KB
testcase_44 AC 39 ms
4,372 KB
testcase_45 AC 1 ms
4,372 KB
testcase_46 AC 4 ms
4,372 KB
testcase_47 AC 1,418 ms
4,372 KB
testcase_48 AC 2 ms
4,372 KB
testcase_49 AC 1 ms
4,368 KB
testcase_50 AC 5 ms
4,372 KB
testcase_51 AC 11 ms
4,368 KB
testcase_52 AC 10 ms
4,372 KB
testcase_53 AC 4 ms
4,368 KB
testcase_54 AC 1 ms
4,368 KB
testcase_55 AC 10 ms
4,368 KB
testcase_56 AC 17 ms
4,368 KB
testcase_57 AC 19 ms
4,372 KB
testcase_58 AC 3 ms
4,372 KB
testcase_59 AC 10 ms
4,368 KB
testcase_60 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
//const int mod = 998244353;
//using mint = modint1000000007;
//const int mod = 1000000007;
//const int INF = 1e9;
const long long LINF = ((long long)1e18) * 2;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
inline long long ceil_div(long long x, long long y) { return (x < 0) ? x / y : (x + (y - 1)) / y; }
inline long long floor_div(long long x, long long y) { return (x < 0) ? (x - (y - 1)) / y : x / y; }
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, l, r; cin >> n >> l >> r;
	r++;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	sort(all(a));
	int ans = 1;
	rep(i, n)rep2(j, i + 1, n) {
		long long x = a[i];
		long long y = a[j];
		long long xy = x * y;
		if ((xy < l) || (r <= xy))continue;
		chmax(ans, 2);
		// [l,r)
		auto f = [&](long long n) {
			if (n > 0) {
				return pair(ceil_div(l, n), ceil_div(r, n));
			}
			else if (0 == n) {
				if (l <= 0 && 0 < r)return pair(-LINF, LINF);
				else return pair(0LL, 0LL);
			}
			else {
				return pair(floor_div(r, n) + 1, floor_div(l, n) + 1);
			}
		};
		auto[m1, M1] = f(x);
		auto[m2, M2] = f(y);
		long long m = max({ m1,m2,x });
		long long M = min({ M1,M2,y + 1 });
		if (m >= M)continue;
		int cnt = lower_bound(all(a), M) - lower_bound(all(a), m);
		for (auto z : { x,y }) {
			cnt -= (m <= z && z < M);
		}
		chmax(ans, cnt + 2);
	}
	cout << ans << endl;
	return 0;
}
0