結果
問題 | No.2961 Shiny Monster Master |
ユーザー |
|
提出日時 | 2024-11-16 16:53:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 1,777 ms |
コード長 | 657 bytes |
コンパイル時間 | 5,925 ms |
コンパイル使用メモリ | 313,248 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-16 16:53:44 |
合計ジャッジ時間 | 9,920 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 77 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using mint=atcoder::modint998244353;#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#define int long longsigned main(){int R,N;cin>>R>>N;vector<int> A(N);for(auto&&e:A)cin>>e;sort(A.begin(),A.end());int Q;cin>>Q;while(Q--){int l,r;cin>>l>>r;if(l/R==r/R){cout<<upper_bound(A.begin(),A.end(),r%R)-lower_bound(A.begin(),A.end(),l%R)<<endl;}else{int t=r/R-l/R-1;int ret=t*N;ret+=A.end()-lower_bound(A.begin(),A.end(),l%R);ret+=upper_bound(A.begin(),A.end(),r%R)-A.begin();cout<<ret<<endl;}}}