結果

問題 No.2961 Shiny Monster Master
ユーザー karinohito
提出日時 2025-01-12 15:07:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 1,777 ms
コード長 493 bytes
コンパイル時間 4,198 ms
コンパイル使用メモリ 197,876 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-12 15:07:21
合計ジャッジ時間 9,873 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll R,N;
vector<ll> A;

ll f(ll X){
    ll res=(X/R)*N;
    X%=R;
    res+=upper_bound(A.begin(),A.end(),X)-A.begin();
    return res;
}

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin>>R>>N;
    A.resize(N);
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A.begin(),A.end());
    ll Q;
    cin>>Q;
    for(int q=0;q<Q;q++){
        ll l,r;
        cin>>l>>r;
        cout<<f(r)-f(l-1)<<"\n";
    }
}
0