#include <bits/stdc++.h>
#define MAXN 500005
using namespace std;
typedef long long ll;
ll n,q;
ll de[MAXN];
ll in[MAXN];
ll binarna(ll l,ll d,ll cilj,ll vreme,ll sol){
if(l>d)return sol;
ll mid=(l+d)/2;
//printf(" %lld %lld",mid,in[mid]);
if(vreme-(vreme%in[mid])-mid>=cilj)return binarna(mid+1,d,cilj,vreme,mid);
else return binarna(l,mid-1,cilj,vreme,sol);
}
int main()
{
scanf("%lld %lld", &n, &q);
for(ll i=1;i<=n;i++)
scanf("%lld",de+i);
in[1]=de[1];
//printf(" %lld\n",in[1]);
for(ll i=2;i<=n;i++){
//printf(" %lld %lld\n",de[i],de[i-1]);
if(in[i-1]>=5e9+7){
in[i]=5e9+7;
continue;
}
ll nak=(de[i]/de[i-1])+ (de[i]%de[i-1]?1:0);
in[i]=nak*in[i-1];
//printf(" %lld\n",in[i]);
}
while(q--){
ll t,a,b;
scanf("%lld %lld %lld", &t, &a, &b);
ll tres=binarna(1,n,a,t,0)-binarna(1,n,b+1,t,0);
if(t>=a && t<=b)tres++;
printf("%lld\n",tres);
}
return 0;
}
Compilation message
worst_reporter3.cpp: In function 'int main()':
worst_reporter3.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &n, &q);
~~~~~^~~~~~~~~~~~~~~~~~~~~
worst_reporter3.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",de+i);
~~~~~^~~~~~~~~~~~~
worst_reporter3.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld", &t, &a, &b);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
922 ms |
11200 KB |
Output is correct |
2 |
Correct |
979 ms |
11240 KB |
Output is correct |
3 |
Correct |
972 ms |
11260 KB |
Output is correct |
4 |
Correct |
1020 ms |
11256 KB |
Output is correct |
5 |
Correct |
918 ms |
11256 KB |
Output is correct |
6 |
Correct |
951 ms |
11200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
922 ms |
11200 KB |
Output is correct |
2 |
Correct |
979 ms |
11240 KB |
Output is correct |
3 |
Correct |
972 ms |
11260 KB |
Output is correct |
4 |
Correct |
1020 ms |
11256 KB |
Output is correct |
5 |
Correct |
918 ms |
11256 KB |
Output is correct |
6 |
Correct |
951 ms |
11200 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |