#include <bits/stdc++.h>
#define rp(_s,_i,_n) for(int _s=_i;_s<_n;_s++)
#define sz(_itt) (int)_itt.size()
#define mp(__a,__b) make_pair(__a,__b)
#define pb(_p) push_back(_p)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define mx 1000004
using namespace std;
typedef long long ll;
int main()
{
fastio
ll n,q;cin>>n>>q;
ll tab[n];
rp(i,0,n)cin>>tab[i];
rp(i,0,q){
ll t,l,r;cin>>t>>l>>r;
ll sl=max(0LL,t-n);
ll sr=max(0LL,t);
ll res=0LL;
res=min(sr,r)-max(sl,l)+1;
if(sr<l||sl>r)res=0;
cout <<res<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
12252 KB |
Output is correct |
2 |
Correct |
292 ms |
12708 KB |
Output is correct |
3 |
Correct |
289 ms |
12572 KB |
Output is correct |
4 |
Correct |
293 ms |
12512 KB |
Output is correct |
5 |
Correct |
293 ms |
12536 KB |
Output is correct |
6 |
Correct |
290 ms |
12468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
297 ms |
12252 KB |
Output is correct |
2 |
Correct |
292 ms |
12708 KB |
Output is correct |
3 |
Correct |
289 ms |
12572 KB |
Output is correct |
4 |
Correct |
293 ms |
12512 KB |
Output is correct |
5 |
Correct |
293 ms |
12536 KB |
Output is correct |
6 |
Correct |
290 ms |
12468 KB |
Output is correct |
7 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |