結果

問題 No.2961 Shiny Monster Master
ユーザー tokitsukaze
提出日時 2025-02-28 15:34:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 1,777 ms
コード長 539 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 195,832 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-02-28 15:34:23
合計ジャッジ時間 5,818 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 77
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d%d",&k,&n);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:12:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         for(i=1;i<=n;i++) scanf("%d",&a[i]);
      |                           ~~~~~^~~~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d",&q);
      |         ~~~~~^~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 scanf("%d%d",&l,&r);
      |                 ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0