#include <bits/stdc++.h>
using namespace std;
const int NMAX = 500*1000;
int distanceNec[NMAX];
int posPersonne[NMAX];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int nbPersonnes, nbRequetes;
cin >> nbPersonnes >> nbRequetes;
bool tout1 = true;
for(int iP = 0; iP < nbPersonnes; iP++)
{
cin >> distanceNec[iP];
if(distanceNec[iP] != 1) tout1 = false;
posPersonne[iP] = -(iP+1);
}
if(tout1)
{
int deb = -nbPersonnes;
int fin = 0;
int a, b;
int j;
for(int iQ = 0; iQ < nbRequetes; iQ++)
{
cin >> j >> a >> b;
a = max(a, deb+j);
b = min(b, fin + j);
// cout << a << " " << b << endl;
if(a > b) cout << "0" << "\n";
else cout << (b-a+1) << "\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
22668 KB |
Output is correct |
2 |
Correct |
185 ms |
22832 KB |
Output is correct |
3 |
Correct |
203 ms |
22840 KB |
Output is correct |
4 |
Correct |
171 ms |
22620 KB |
Output is correct |
5 |
Correct |
209 ms |
22612 KB |
Output is correct |
6 |
Correct |
191 ms |
22752 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
22668 KB |
Output is correct |
2 |
Correct |
185 ms |
22832 KB |
Output is correct |
3 |
Correct |
203 ms |
22840 KB |
Output is correct |
4 |
Correct |
171 ms |
22620 KB |
Output is correct |
5 |
Correct |
209 ms |
22612 KB |
Output is correct |
6 |
Correct |
191 ms |
22752 KB |
Output is correct |
7 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |