Submission #1356697

#TimeUsernameProblemLanguageResultExecution timeMemory
1356697JohanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
8 / 100
3094 ms23952 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
const int INF = 1e18;
int l, r, k;
bool cmp(pair < int , int > a, pair < int , int > b){
    
}
signed main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector < int > a(n);
  for(int &i : a)cin >> i;
  while(q--){
    cin >> l >> r >> k;
    l--, r--;
    vector < int > v;
    for(int i = l; i <= r; i++)
      v.push_back(a[i]);
    for(int i = 1; i < v.size(); i++){ 
      int j = i;
      while(j > 0 && v[j] < v[j - 1] && v[j] + v[j - 1] <= k){
        swap(v[j], v[j - 1]);
        j--;
      }
    }
    if(is_sorted(v.begin(), v.end()) == true){
      cout << 1 << endl;
    }
    else {
      cout << 0 << endl;
    }
  }
}

Compilation message (stderr)

sortbooks.cpp: In function 'bool cmp(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
sortbooks.cpp:9:1: warning: no return statement in function returning non-void [-Wreturn-type]
    9 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...