Submission #553469

# Submission time Handle Problem Language Result Execution time Memory
553469 2022-04-25T23:49:40 Z MohamedAhmed04 Worst Reporter 3 (JOI18_worst_reporter3) C++14
100 / 100
564 ms 25364 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 5e5 + 10 ;

long long arr[MAX] ;
int n , q ;

bool check(int idx , int x , int t)
{
	return (-idx + t / arr[idx] * arr[idx] <= x) ;
}

int calc(int x , int t)
{
	int l = 0 , r = n ;
	int ans = n+1 ;
	while(l <= r)
	{
		int mid = (l + r) >> 1 ;
		if(check(mid , x , t))
			ans = mid , r = mid-1 ;
		else
			l = mid+1 ;
	}
	return (n-ans+1) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>q ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	arr[0] = 1 ;
	for(int i = 1 ; i <= n ; ++i)
		arr[i] = (arr[i] + arr[i-1] - 1) / arr[i-1] * arr[i-1] ;
	while(q--)
	{
		int t , l , r ;
		cin>>t>>l>>r ;
		cout<<calc(r , t) - calc(l-1 , t)<<"\n" ;
	}
	return 0 ;
}		
# Verdict Execution time Memory Grader output
1 Correct 523 ms 7224 KB Output is correct
2 Correct 537 ms 7160 KB Output is correct
3 Correct 539 ms 7320 KB Output is correct
4 Correct 531 ms 7180 KB Output is correct
5 Correct 507 ms 7116 KB Output is correct
6 Correct 491 ms 7116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 523 ms 7224 KB Output is correct
2 Correct 537 ms 7160 KB Output is correct
3 Correct 539 ms 7320 KB Output is correct
4 Correct 531 ms 7180 KB Output is correct
5 Correct 507 ms 7116 KB Output is correct
6 Correct 491 ms 7116 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 314 ms 16116 KB Output is correct
14 Correct 380 ms 21964 KB Output is correct
15 Correct 341 ms 20396 KB Output is correct
16 Correct 337 ms 20932 KB Output is correct
17 Correct 404 ms 25180 KB Output is correct
18 Correct 400 ms 25204 KB Output is correct
19 Correct 386 ms 25280 KB Output is correct
20 Correct 486 ms 25176 KB Output is correct
21 Correct 444 ms 25244 KB Output is correct
22 Correct 423 ms 25196 KB Output is correct
23 Correct 404 ms 25364 KB Output is correct
24 Correct 407 ms 25284 KB Output is correct
25 Correct 564 ms 22652 KB Output is correct
26 Correct 557 ms 22688 KB Output is correct
27 Correct 438 ms 24764 KB Output is correct
28 Correct 417 ms 25096 KB Output is correct
29 Correct 454 ms 24692 KB Output is correct
30 Correct 437 ms 24920 KB Output is correct
31 Correct 429 ms 25072 KB Output is correct
32 Correct 474 ms 21252 KB Output is correct
33 Correct 0 ms 212 KB Output is correct