답안 #58910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58910 2018-07-19T19:23:13 Z TadijaSebez Worst Reporter 3 (JOI18_worst_reporter3) C++11
100 / 100
1178 ms 186284 KB
#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;
}

Compilation message

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);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1114 ms 20292 KB Output is correct
2 Correct 1006 ms 20292 KB Output is correct
3 Correct 1178 ms 20416 KB Output is correct
4 Correct 1142 ms 20416 KB Output is correct
5 Correct 1165 ms 20416 KB Output is correct
6 Correct 1162 ms 20416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 20416 KB Output is correct
2 Correct 3 ms 20416 KB Output is correct
3 Correct 3 ms 20416 KB Output is correct
4 Correct 3 ms 20416 KB Output is correct
5 Correct 3 ms 20416 KB Output is correct
6 Correct 4 ms 20416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1114 ms 20292 KB Output is correct
2 Correct 1006 ms 20292 KB Output is correct
3 Correct 1178 ms 20416 KB Output is correct
4 Correct 1142 ms 20416 KB Output is correct
5 Correct 1165 ms 20416 KB Output is correct
6 Correct 1162 ms 20416 KB Output is correct
7 Correct 5 ms 20416 KB Output is correct
8 Correct 3 ms 20416 KB Output is correct
9 Correct 3 ms 20416 KB Output is correct
10 Correct 3 ms 20416 KB Output is correct
11 Correct 3 ms 20416 KB Output is correct
12 Correct 4 ms 20416 KB Output is correct
13 Correct 606 ms 20416 KB Output is correct
14 Correct 659 ms 20416 KB Output is correct
15 Correct 660 ms 20416 KB Output is correct
16 Correct 703 ms 20416 KB Output is correct
17 Correct 841 ms 20416 KB Output is correct
18 Correct 844 ms 20416 KB Output is correct
19 Correct 840 ms 20416 KB Output is correct
20 Correct 830 ms 20416 KB Output is correct
21 Correct 837 ms 20416 KB Output is correct
22 Correct 741 ms 20416 KB Output is correct
23 Correct 894 ms 38536 KB Output is correct
24 Correct 818 ms 57176 KB Output is correct
25 Correct 1050 ms 73184 KB Output is correct
26 Correct 941 ms 88508 KB Output is correct
27 Correct 838 ms 106272 KB Output is correct
28 Correct 831 ms 124340 KB Output is correct
29 Correct 786 ms 141292 KB Output is correct
30 Correct 941 ms 158548 KB Output is correct
31 Correct 971 ms 174800 KB Output is correct
32 Correct 934 ms 186284 KB Output is correct
33 Correct 4 ms 186284 KB Output is correct