結果
問題 | No.2500 Products in a Range |
ユーザー |
|
提出日時 | 2023-10-13 22:27:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,038 bytes |
コンパイル時間 | 1,766 ms |
コンパイル使用メモリ | 176,596 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-15 18:12:20 |
合計ジャッジ時間 | 9,114 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 RE * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:28:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 28 | auto[l,r] = range.at(i); | ^ main.cpp:33:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 33 | auto[l2,r2] = range.at(k); | ^
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){ios_base::sync_with_stdio(false);cin.tie(nullptr);long long N,L,R; cin >> N >> L >> R;vector<long long> A(N);for(auto &a : A) cin >> a;sort(A.begin(),A.end());vector<pair<int,int>> range(N);for(int i=0; i<N; i++){long long l = L,r = R,a = A.at(i),mina,maxa;if(a < 0){mina = r/abs(a)*(-1),maxa = (l-a-1)/abs(a)*(-1);}else{mina = (l+a-1)/a; maxa = r/a;}int posl = lower_bound(A.begin()+i+1,A.end(),mina)-A.begin();int posr = upper_bound(A.begin()+i+1,A.end(),maxa)-A.begin();posr--;range.at(i) = {posl,posr};}vector<int> B(N,1);for(int i=0; i<N; i++){auto[l,r] = range.at(i);int now = 1;for(int k=l; k<=r; ){now++;auto[l2,r2] = range.at(k);k = max(k+1,l2); r = min(r2,r);}B.at(i) = now;}int answer = *max_element(B.begin(),B.end());cout << answer << endl;}