This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |