제출 #58910

#제출 시각아이디문제언어결과실행 시간메모리
58910TadijaSebezWorst Reporter 3 (JOI18_worst_reporter3)C++11
100 / 100
1178 ms186284 KiB
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
const int N=500050;
ll jump[N];
int main()
{
	int n,q,i;
	ll x,l,r,t;
	scanf("%i %i",&n,&q);
	jump[0]=1;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		jump[i]=((x+jump[i-1]-1)/jump[i-1])*jump[i-1];
		if(jump[i]>=2e9) jump[i]=2e9;
	}
	while(q--)
	{
		scanf("%lld %lld %lld",&t,&l,&r);
		int top=n,bot=0,mid,L=0;
		while(top>=bot)
		{
			mid=top+bot>>1;
			if(t/jump[mid]*jump[mid]-mid>=l) L=mid+1,bot=mid+1;
			else top=mid-1;
		}
		top=n,bot=0;int R=0;
		while(top>=bot)
		{
			mid=top+bot>>1;
			if(t/jump[mid]*jump[mid]-mid>r) R=mid+1,bot=mid+1;
			else top=mid-1;
		}
		printf("%i\n",L-R);
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:26:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
worst_reporter3.cpp:33:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
worst_reporter3.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&q);
  ~~~~~^~~~~~~~~~~~~~~
worst_reporter3.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&x);
   ~~~~~^~~~~~~~~~~
worst_reporter3.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld",&t,&l,&r);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...