#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
ll _abs (ll x ) { return (x>0?x:-x); }
const int N =500005 ;
int D[N] ;
int main(){
fastio ;
int n , q;
cin >> n >> q ;
for(int i = 0 ; i <n ;i++ ) cin >> D[i] ;
int t , l , r ;
while ( q-- ){
cin >> t >> l >> r ;
int x = t - n ;
// cout << x << " " << t << endl;
if( l > t || r < x )cout << 0 << endl;
else cout << min( r , t ) - max ( l , x ) + 1 << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1620 ms |
21008 KB |
Output is correct |
2 |
Correct |
1630 ms |
21024 KB |
Output is correct |
3 |
Correct |
1627 ms |
20876 KB |
Output is correct |
4 |
Correct |
1640 ms |
20904 KB |
Output is correct |
5 |
Correct |
1632 ms |
20956 KB |
Output is correct |
6 |
Correct |
1623 ms |
20856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1620 ms |
21008 KB |
Output is correct |
2 |
Correct |
1630 ms |
21024 KB |
Output is correct |
3 |
Correct |
1627 ms |
20876 KB |
Output is correct |
4 |
Correct |
1640 ms |
20904 KB |
Output is correct |
5 |
Correct |
1632 ms |
20956 KB |
Output is correct |
6 |
Correct |
1623 ms |
20856 KB |
Output is correct |
7 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |