Submission #58909

# Submission time Handle Problem Language Result Execution time Memory
58909 2018-07-19T19:20:48 Z TadijaSebez Worst Reporter 3 (JOI18_worst_reporter3) C++11
19 / 100
1232 ms 263168 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];
	}
	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:25:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    mid=top+bot>>1;
        ~~~^~~~
worst_reporter3.cpp:32: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:21: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 time Memory Grader output
1 Correct 936 ms 22780 KB Output is correct
2 Correct 1066 ms 38272 KB Output is correct
3 Correct 1106 ms 53660 KB Output is correct
4 Correct 1164 ms 69332 KB Output is correct
5 Correct 1232 ms 84760 KB Output is correct
6 Correct 1170 ms 100124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 100124 KB Output is correct
2 Correct 3 ms 100124 KB Output is correct
3 Correct 3 ms 100124 KB Output is correct
4 Correct 3 ms 100124 KB Output is correct
5 Correct 3 ms 100124 KB Output is correct
6 Correct 3 ms 100124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 936 ms 22780 KB Output is correct
2 Correct 1066 ms 38272 KB Output is correct
3 Correct 1106 ms 53660 KB Output is correct
4 Correct 1164 ms 69332 KB Output is correct
5 Correct 1232 ms 84760 KB Output is correct
6 Correct 1170 ms 100124 KB Output is correct
7 Correct 4 ms 100124 KB Output is correct
8 Correct 3 ms 100124 KB Output is correct
9 Correct 3 ms 100124 KB Output is correct
10 Correct 3 ms 100124 KB Output is correct
11 Correct 3 ms 100124 KB Output is correct
12 Correct 3 ms 100124 KB Output is correct
13 Correct 601 ms 114400 KB Output is correct
14 Correct 654 ms 131020 KB Output is correct
15 Correct 609 ms 146188 KB Output is correct
16 Correct 614 ms 162108 KB Output is correct
17 Correct 845 ms 181716 KB Output is correct
18 Correct 993 ms 199244 KB Output is correct
19 Correct 811 ms 217980 KB Output is correct
20 Correct 796 ms 236212 KB Output is correct
21 Correct 892 ms 253020 KB Output is correct
22 Runtime error 919 ms 263168 KB Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience.
23 Halted 0 ms 0 KB -