結果

問題 No.2500 Products in a Range
ユーザー GOTKAKOGOTKAKO
提出日時 2023-10-13 22:27:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,038 bytes
コンパイル時間 1,729 ms
コンパイル使用メモリ 175,616 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 22:27:54
合計ジャッジ時間 8,631 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 25 ms
4,348 KB
testcase_11 AC 33 ms
4,348 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 48 ms
4,348 KB
testcase_26 AC 48 ms
4,352 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 12 ms
4,348 KB
testcase_34 AC 29 ms
4,348 KB
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 2 ms
4,352 KB
testcase_40 AC 2 ms
4,352 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,352 KB
testcase_43 AC 1 ms
4,348 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 AC 47 ms
4,352 KB
testcase_48 AC 4 ms
4,352 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 1 ms
4,352 KB
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:28:13: 警告: 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: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   33 |             auto[l2,r2] = range.at(k);
      |                 ^

ソースコード

diff #

#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;

}
0