#include<bits/stdc++.h>
#define int long long
using namespace std;
int t[600000];
int suma[600000];
int n;
int licz(int kiedy,int x)
{
int pocz=0,kon=n,sre;
while(pocz<=kon)
{
sre=(pocz+kon)/2;
if(kiedy/suma[sre]*suma[sre]-sre>=x)
pocz=sre+1;
else kon=sre-1;
}
return kon+1;
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int zap,tt,l,r;
cin>>n>>zap;
for(int i=1;i<=n;i++)
cin>>t[i];
suma[0]=1;
for(int i=1;i<=n;i++)
{
suma[i]=max(t[i],suma[i-1]);
suma[i]=suma[i-1]*((suma[i-1]+suma[i]-1)/suma[i-1]);
}
while(zap--)
{
cin>>tt>>l>>r;
cout<<licz(tt,l)-licz(tt,r+1)<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
425 ms |
27476 KB |
Output is correct |
2 |
Correct |
420 ms |
27512 KB |
Output is correct |
3 |
Correct |
423 ms |
27412 KB |
Output is correct |
4 |
Correct |
435 ms |
27428 KB |
Output is correct |
5 |
Correct |
420 ms |
27292 KB |
Output is correct |
6 |
Correct |
423 ms |
27484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2524 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
425 ms |
27476 KB |
Output is correct |
2 |
Correct |
420 ms |
27512 KB |
Output is correct |
3 |
Correct |
423 ms |
27412 KB |
Output is correct |
4 |
Correct |
435 ms |
27428 KB |
Output is correct |
5 |
Correct |
420 ms |
27292 KB |
Output is correct |
6 |
Correct |
423 ms |
27484 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2524 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2524 KB |
Output is correct |
13 |
Correct |
251 ms |
25864 KB |
Output is correct |
14 |
Correct |
264 ms |
26496 KB |
Output is correct |
15 |
Correct |
247 ms |
25332 KB |
Output is correct |
16 |
Correct |
256 ms |
25684 KB |
Output is correct |
17 |
Correct |
341 ms |
30248 KB |
Output is correct |
18 |
Correct |
317 ms |
30012 KB |
Output is correct |
19 |
Correct |
319 ms |
30060 KB |
Output is correct |
20 |
Correct |
315 ms |
30032 KB |
Output is correct |
21 |
Correct |
322 ms |
30020 KB |
Output is correct |
22 |
Correct |
339 ms |
30004 KB |
Output is correct |
23 |
Correct |
318 ms |
29900 KB |
Output is correct |
24 |
Correct |
317 ms |
30144 KB |
Output is correct |
25 |
Correct |
418 ms |
27476 KB |
Output is correct |
26 |
Correct |
430 ms |
27372 KB |
Output is correct |
27 |
Correct |
352 ms |
29436 KB |
Output is correct |
28 |
Correct |
354 ms |
29780 KB |
Output is correct |
29 |
Correct |
345 ms |
29384 KB |
Output is correct |
30 |
Correct |
345 ms |
29572 KB |
Output is correct |
31 |
Correct |
351 ms |
29828 KB |
Output is correct |
32 |
Correct |
328 ms |
26048 KB |
Output is correct |
33 |
Correct |
1 ms |
2392 KB |
Output is correct |