#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;
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]);
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:19: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:21: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:33: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);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
941 ms |
26616 KB |
Output is correct |
2 |
Correct |
1002 ms |
26668 KB |
Output is correct |
3 |
Correct |
1010 ms |
26688 KB |
Output is correct |
4 |
Correct |
956 ms |
26820 KB |
Output is correct |
5 |
Correct |
930 ms |
26616 KB |
Output is correct |
6 |
Correct |
968 ms |
26872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
941 ms |
26616 KB |
Output is correct |
2 |
Correct |
1002 ms |
26668 KB |
Output is correct |
3 |
Correct |
1010 ms |
26688 KB |
Output is correct |
4 |
Correct |
956 ms |
26820 KB |
Output is correct |
5 |
Correct |
930 ms |
26616 KB |
Output is correct |
6 |
Correct |
968 ms |
26872 KB |
Output is correct |
7 |
Runtime error |
4 ms |
512 KB |
Execution killed with signal 8 (could be triggered by violating memory limits) |
8 |
Halted |
0 ms |
0 KB |
- |