結果
問題 | No.2500 Products in a Range |
ユーザー |
|
提出日時 | 2023-10-13 21:11:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,178 bytes |
コンパイル時間 | 1,002 ms |
コンパイル使用メモリ | 125,052 KB |
最終ジャッジ日時 | 2025-02-17 06:59:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 59 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:83:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 83 | scanf("%d%lld%lld", &n, &l, &r); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:85:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 85 | scanf("%lld", &a[i]); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
//#pragma GCC optimize("Ofast") //#pragma GCC target("avx,avx2,fma") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,avx,avx2,popcnt,tune=native") #include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <bitset> #include <array> #include <climits> using namespace std; #ifdef LOCAL #define eprintf(...) {fprintf(stderr, __VA_ARGS__);fflush(stderr);} #else #define eprintf(...) 42 #endif using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; using pii = pair<int, int>; using pli = pair<ll, int>; using pll = pair<ll, ll>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } #define mp make_pair #define all(x) (x).begin(),(x).end() clock_t startTime; double getCurrentTime() { return (double)(clock() - startTime) / CLOCKS_PER_SEC; } ll floor_div(ll x, ll y) { assert(y != 0); if (y < 0) { y = -y; x = -x; } if (x >= 0) return x / y; return (x + 1) / y - 1; } ll ceil_div(ll x, ll y) { assert(y != 0); if (y < 0) { y = -y; x = -x; } if (x <= 0) return x / y; return (x - 1) / y + 1; } const int N = 5050; int n; ll a[N]; ll l, r; int ans; int main() { startTime = clock(); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); scanf("%d%lld%lld", &n, &l, &r); for (int i = 0; i < n; i++) scanf("%lld", &a[i]); sort(a, a + n); ans = 1; if (r < 0) { for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { ll x = a[i] * a[j]; if (l <= x && x <= r) ans = 2; } printf("%d\n", ans); return 0; } for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { ll x = a[i] * a[i + 1]; ll y = a[i] * a[j]; ll z = a[j - 1] * a[j]; if (min(x, min(y, z)) < l || max(x, max(y, z)) > r) continue; ans = max(ans, j - i + 1); } printf("%d\n", ans); return 0; }