結果
問題 | No.2961 Shiny Monster Master |
ユーザー |
![]() |
提出日時 | 2024-11-18 11:38:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 1,777 ms |
コード長 | 637 bytes |
コンパイル時間 | 2,135 ms |
コンパイル使用メモリ | 198,528 KB |
最終ジャッジ日時 | 2025-02-25 05:23:30 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 77 |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/modint> using namespace std; //using namespace atcoder; using ll = long long; //using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll R, N, Q, l, r; cin >> R >> N; vector<ll> A(N); for (int i=0; i<N; i++) cin >> A[i]; sort(A.begin(), A.end()); cin >> Q; //[0,x]での答え auto f=[&](ll x){ ll res= x/R * N; res += upper_bound(A.begin(), A.end(), x%R)-A.begin(); return res; }; while(Q--){ cin >> l >> r; cout << f(r)-f(l-1) << endl; } return 0; }