이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define N 1000005
#define INF 1e9+5
#define sp " "
#define endl "\n"
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
int n,m,w[N],s[N],l,r,k,rq,lq,mx1,mx2;
int main(){
cin >> n >> m;
for(int i=0;i<n;i++){
cin >> w[i];
s[i]=w[i];
}
sort(s,s+n);
for(int i=0;i<m;i++){
cin >> l >> r >> k;
mx1=mx2=0;
rq=lq=l;
int j=l;
while(j<=r&&w[j]==s[j]){
j++;
}
if(j>r){
continue;
}
lq=j;
for(j;j<=r;j++){
if(w[j]!=s[j]){
rq=j;
}
}
for(int j=lq;j<=rq;j++){
if(w[i]>mx1){
mx2=mx1;
mx1=w[i];
}
else if(w[i]<=mx1&&w[i]>mx2){
mx2=w[i];
}
}
if(mx1+mx2>k){
cout << 0 << endl;
}
else{
cout << 1 << endl;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:37:13: warning: statement has no effect [-Wunused-value]
37 | for(j;j<=r;j++){
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |