結果
問題 | No.2961 Shiny Monster Master |
ユーザー |
|
提出日時 | 2024-11-16 16:04:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,777 ms |
コード長 | 1,164 bytes |
コンパイル時間 | 1,233 ms |
コンパイル使用メモリ | 80,924 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 16:04:42 |
合計ジャッジ時間 | 4,153 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 77 |
ソースコード
// Sat Nov 16 09:57:41 2024// Problem "No.2961 Shiny Monster Master" in contest "unknown_contest"#include <algorithm>#include <vector>#pragma GCC optimize("O3")#include <stdio.h>#ifdef NOJUDGE#define debug(...) fprintf(stderr, __VA_ARGS__)#else#define debug(...)#endifusing namespace std;typedef long long int ll;const ll MOD = 1000000007;const ll MOD2 = 998244353;inline void solve() {ll n, R;scanf("%lld %lld", &R, &n);vector<ll> a(n);for (ll i = 0; i < n; i++) {scanf("%lld", &a[i]);}sort(a.begin(), a.end());auto count = [&](ll z) -> ll {ll x = z / R * n;ll y = lower_bound(a.begin(), a.end(), z % R) - a.begin();debug("Count up to %lld: %lld + %lld = %lld\n", n, x, y, x + y);return x + y;};auto query = [&](ll l, ll r) -> ll { return count(r + 1) - count(l); };ll q;scanf("%lld", &q);for (ll i = 0; i < q; i++) {ll l, r;scanf("%lld %lld", &l, &r);printf("%lld\n", query(l, r));}}#define yukicoderint main() {#if defined(Codeforces) || defined(CodeChef)ll t;scanf("%lld", &t);for (int i = 0; i < t; i++) {solve();}#elsesolve();#endif}