이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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-1);
ll res=0LL;
if(l>=sl&&l<=sr&&r>=sl&&r<=sr)res=l-r+1;
else if(r<=sr&&r>=sl&&l<=sl)res=r-sl+1;
else if(l>=sl&&l<=sr&&r>=sr)res=sr-l+1;
if(t>=l&&t<=r)res++;
cout << res<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |