#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define all(x) x.begin(),x.end()
#define al(a,n) (a,a+n)
#define se second
#define fr first
#define m_p make_pair
const ll N = 2000004;
const ll mod = 1000 * 1000 * 1000 + 7;
const ll inf = 1000000000;
ll n, m, k, z, t, ans, x,y, pat,a[N];
int main()
{
cin >> n >> m;
k = m;
for (int i = 0; i < n; ++i)
cin >> a[i];
map <ll, ll> mp;
int j = 0;
for (int i = 0; i < n; ++i)
{
j = max(j, i);
while (j < n - 1 && a[j] <= a[j + 1])
++j;
mp[i] = j;
}
while (m--)
{
cin >> x >> y >> z;
x--;
y--;
if (mp[x] >= y)
{
cout << 1 << endl;
continue;
}
vector<ll> v,s;
for (int i = x; i <= y; ++i)
{
v.push_back(a[i]);
}
s = v;
sort(all(v));
ll p = 0;
for (int i = v.size() - 1; i >= 0; --i)
{
if (v[i] != s[i])
{
p = v[i];
break;
}
}
if (v[0] + p > z)
cout << 0 << endl;
else
cout << 1 << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3067 ms |
85212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3093 ms |
9344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
2 ms |
332 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |