이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
    ll book_weight[5001];
int main(){
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<n;i++){
        cin>>book_weight[i];
    }
    for(ll i=0;i<m;i++){
        ll l,r,k;
        cin>>l>>r>>k;
        l--; r--;
        vector<ll> books_sorted;
        books_sorted.push_back(book_weight[l]);
        bool is_possible=true;
        for(ll j=1;j<=r-l;j++){
            books_sorted.push_back(book_weight[l+j]);
            ll x=j;
            while(books_sorted[x]<books_sorted[x-1]){
                if(k<books_sorted[x]+books_sorted[x-1]){
                    is_possible=false;
                    break;
                }
                swap(books_sorted[x],books_sorted[x-1]);
                x--;
                if(x==0)break;
            }
        }
        if(is_possible){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }
    return 0;
}
| # | 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... |