結果
| 問題 | 
                            No.2500 Products in a Range
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-10-14 00:08:46 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 374 ms / 2,000 ms | 
| コード長 | 1,234 bytes | 
| コンパイル時間 | 1,894 ms | 
| コンパイル使用メモリ | 200,348 KB | 
| 最終ジャッジ日時 | 2025-02-17 07:42:10 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 61 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  long long N, L, R;
  cin >> N >> L >> R;
  vector<long long> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int ans = 1;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      if(j - i <= 4) {
        bool fn = true;
        for(int k = i; k < j; k++) {
          for(int l = k + 1; l <= j; l++) {
            if(A[k] * A[l] < L || A[k] * A[l] > R) {
              fn = false;
            }
          }
        }
        if(fn) {
          ans = max(ans, j - i + 1);
        }
      } else {
        vector<long long> B = {A[i], A[i + 1], A[j - 1], A[j]};
        bool fn = true;
        for(int k = 0; k < 4; k++) {
          for(int l = k + 1; l < 4; l++) {
            if(B[k] * B[l] < L || B[k] * B[l] > R) {
              fn = false;
            }
          }
        }
        if(fn) {
          ans = max(ans, j - i + 1);
        }
      }
    }
  }
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      if(L <= A[i] * A[j] && A[i] * A[j] <= R) {
        ans = max(ans, 2);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}