#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,avx2")
#pragma GCC optimize("unroll-loops,O2")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pll;
constexpr ll N = 5e5+10,mod = 998244353,inf = 1e9+10,lg = 20;
inline int mkay(int a,int b){
if (a+b >= mod) return a+b-mod;
if (a+b < 0) return a+b+mod;
return a+b;
}
inline int poww(int a,int k){
if (k < 0) return 0;
int z = 1;
while (k){
if (k&1) z = 1ll*z*a%mod;
a = 1ll*a*a%mod;
k /= 2;
}
return z;
}
int d[N];
int main(){
ios :: sync_with_stdio(0); cin.tie(0);
int n,q;
cin >> n >> q;
bool fl = 1;
rep(i,1,n+1){
cin >> d[i];
if (d[i] != 1) fl = 0;
}
if (fl){
while (q--){
int t,l,r;
cin >> t >> l >> r;
if (t < l || t-n > r){
cout << 0 << endl;
continue;
}
cout << min(t,r)-max(l,t-n)+1 << endl;
}
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
235 ms |
20740 KB |
Output is correct |
2 |
Correct |
250 ms |
20684 KB |
Output is correct |
3 |
Correct |
227 ms |
20736 KB |
Output is correct |
4 |
Correct |
236 ms |
20644 KB |
Output is correct |
5 |
Correct |
292 ms |
20724 KB |
Output is correct |
6 |
Correct |
222 ms |
20812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
235 ms |
20740 KB |
Output is correct |
2 |
Correct |
250 ms |
20684 KB |
Output is correct |
3 |
Correct |
227 ms |
20736 KB |
Output is correct |
4 |
Correct |
236 ms |
20644 KB |
Output is correct |
5 |
Correct |
292 ms |
20724 KB |
Output is correct |
6 |
Correct |
222 ms |
20812 KB |
Output is correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |