#include<bits/stdc++.h>
using namespace std;
int a,b,c[1000010],d,e,f,g=1,h,i,j,k,l=99999999,n,m;
main(){ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>a>>b;
for (i=1; i<=a; i++)
{cin>>c[i];
l=min(l,c[i]);
n=max(n,c[i]);
}
for (i=1; i<=a; i++)
{if (n==c[i]) continue;
else m=max(c[i],m);
}
for (i=1; i<=b; i++)
{cin>>d>>e>>f;
if (m+n<=f) {cout<<'1'<<" "; continue;}
for (j=d; j<=e; j++)
{if (l+n<=f&&l==c[j]) continue;
for (k=j+1; k<=e; k++)
{if (c[j]>c[k]&&c[j]+c[k]>f){g=0; break;}
}
if (g==0) break;
}
cout<<g<<" ";
g=1;
}
}
Compilation message
sortbooks.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){ios::sync_with_stdio(false);
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
6 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
6 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
17 ms |
340 KB |
Output is correct |
12 |
Correct |
132 ms |
340 KB |
Output is correct |
13 |
Correct |
90 ms |
332 KB |
Output is correct |
14 |
Correct |
158 ms |
340 KB |
Output is correct |
15 |
Correct |
129 ms |
352 KB |
Output is correct |
16 |
Execution timed out |
3082 ms |
384 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
469 ms |
6136 KB |
Output is correct |
2 |
Correct |
477 ms |
6228 KB |
Output is correct |
3 |
Correct |
488 ms |
6268 KB |
Output is correct |
4 |
Correct |
449 ms |
6256 KB |
Output is correct |
5 |
Execution timed out |
3068 ms |
4200 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3062 ms |
1088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
6 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
17 ms |
340 KB |
Output is correct |
12 |
Correct |
132 ms |
340 KB |
Output is correct |
13 |
Correct |
90 ms |
332 KB |
Output is correct |
14 |
Correct |
158 ms |
340 KB |
Output is correct |
15 |
Correct |
129 ms |
352 KB |
Output is correct |
16 |
Execution timed out |
3082 ms |
384 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
6 ms |
212 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
17 ms |
340 KB |
Output is correct |
12 |
Correct |
132 ms |
340 KB |
Output is correct |
13 |
Correct |
90 ms |
332 KB |
Output is correct |
14 |
Correct |
158 ms |
340 KB |
Output is correct |
15 |
Correct |
129 ms |
352 KB |
Output is correct |
16 |
Execution timed out |
3082 ms |
384 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |