結果

問題 No.2500 Products in a Range
ユーザー kwm_tkwm_t
提出日時 2023-10-15 16:14:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,408 ms / 2,000 ms
コード長 1,969 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 205,120 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-15 16:15:02
合計ジャッジ時間 14,262 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 12 ms
4,348 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 6 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 116 ms
4,352 KB
testcase_08 AC 209 ms
4,352 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 705 ms
4,352 KB
testcase_11 AC 937 ms
4,352 KB
testcase_12 AC 321 ms
4,352 KB
testcase_13 AC 9 ms
4,352 KB
testcase_14 AC 478 ms
4,348 KB
testcase_15 AC 22 ms
4,348 KB
testcase_16 AC 9 ms
4,352 KB
testcase_17 AC 5 ms
4,352 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 AC 11 ms
4,348 KB
testcase_20 AC 12 ms
4,368 KB
testcase_21 AC 2 ms
4,368 KB
testcase_22 AC 47 ms
4,352 KB
testcase_23 AC 31 ms
4,348 KB
testcase_24 AC 35 ms
4,348 KB
testcase_25 AC 1,405 ms
4,352 KB
testcase_26 AC 1,408 ms
4,356 KB
testcase_27 AC 1,402 ms
4,352 KB
testcase_28 AC 10 ms
4,352 KB
testcase_29 AC 4 ms
4,356 KB
testcase_30 AC 3 ms
4,356 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 2 ms
4,352 KB
testcase_33 AC 283 ms
4,352 KB
testcase_34 AC 785 ms
4,356 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 AC 1 ms
4,352 KB
testcase_38 AC 1 ms
4,352 KB
testcase_39 AC 1 ms
4,352 KB
testcase_40 AC 1 ms
4,372 KB
testcase_41 AC 1 ms
4,348 KB
testcase_42 AC 1 ms
4,352 KB
testcase_43 AC 1 ms
4,352 KB
testcase_44 AC 39 ms
4,352 KB
testcase_45 AC 1 ms
4,352 KB
testcase_46 AC 4 ms
4,372 KB
testcase_47 AC 1,401 ms
4,352 KB
testcase_48 AC 2 ms
4,356 KB
testcase_49 AC 1 ms
4,352 KB
testcase_50 AC 5 ms
4,356 KB
testcase_51 AC 11 ms
4,348 KB
testcase_52 AC 10 ms
4,348 KB
testcase_53 AC 3 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 10 ms
4,352 KB
testcase_56 AC 17 ms
4,352 KB
testcase_57 AC 19 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 11 ms
4,348 KB
testcase_60 AC 2 ms
4,348 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 / y + ((x ^ y) > 0 && x % y != 0); }
inline long long floor_div(long long x, long long y) { return x / y - ((x ^ y) < 0 && x % y != 0); }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