結果
問題 | No.2500 Products in a Range |
ユーザー |
|
提出日時 | 2023-10-13 23:17:17 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,438 bytes |
コンパイル時間 | 2,416 ms |
コンパイル使用メモリ | 208,344 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-15 19:08:53 |
合計ジャッジ時間 | 11,472 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 59 WA * 2 |
ソースコード
#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), C; 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 <= 3) { 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); } } } } if(R < 0) { vector<long long> neg, pos; for(int i = 0; i < N; i++) { if(A[i] < 0) { neg.emplace_back(A[i]); } if(A[i] > 0) { pos.emplace_back(A[i]); } } for(long long x : neg) { for(long long y : pos) { if(L <= x * y && x * y <= R) { ans = max(ans, 2); } } } } cout << ans << '\n'; return 0; }