#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 (n*k > 5000 * 5000)
{
if (mp[x] < y)
cout << 0 << endl;
else
cout << 1 << endl;
}
else
{
vector<ll> v;
for (int i = x; i <= y; ++i)
{
v.push_back(a[x]);
}
sort(all(v));
ll p = 0;
for (int i = v.size() - 1; i >= 0; ++i)
{
if (v[i] != a[i])
{
p = v[i];
break;
}
}
if (v[0] + p > z)
cout << 0 << endl;
else
cout << 1 << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3071 ms |
81860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
351 ms |
9504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |