結果

問題 No.2961 Shiny Monster Master
コンテスト
ユーザー vjudge1
提出日時 2025-02-28 15:26:54
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 539 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,115 ms
コンパイル使用メモリ 213,400 KB
実行使用メモリ 9,300 KB
最終ジャッジ日時 2026-07-06 11:12:28
合計ジャッジ時間 6,318 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 76
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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+=lower_bound(a+1,a+1+n,r)-a-1;
		}
		printf("%d\n",ans);
	}
	return 0;
}
0