結果
| 問題 | No.2961 Shiny Monster Master |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-28 15:31:56 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 1,777 ms |
| コード長 | 539 bytes |
| 記録 | |
| コンパイル時間 | 1,053 ms |
| コンパイル使用メモリ | 215,656 KB |
| 実行使用メモリ | 9,232 KB |
| 最終ジャッジ日時 | 2026-07-06 11:12:39 |
| 合計ジャッジ時間 | 4,599 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 77 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const int MAX=1e5+10;
int a[MAX];
int main()
{
int k,n,i,q,l,r,ans;
scanf("%d%d",&k,&n);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
sort(a+1,a+1+n);
scanf("%d",&q);
while(q--)
{
scanf("%d%d",&l,&r);
ans=(r+1)/k*n-(l+k-1)/k*n;
if(l%k)
{
l%=k;
ans+=n-(lower_bound(a+1,a+1+n,l)-a)+1;
}
if(r%k!=k-1)
{
r%=k;
ans+=upper_bound(a+1,a+1+n,r)-a-1;
}
printf("%d\n",ans);
}
return 0;
}
vjudge1