Submission #493191

#TimeUsernameProblemLanguageResultExecution timeMemory
493191irmuunHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3050 ms8632 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long #define ff first #define ss second #define PI 3.14159265359 int main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mn=1e9,a; vector<ll>v; cin>>n>>m; for(i=1;i<=n;i++){ cin>>w[i]; if(i>1){ if(w[i]<w[i-1]){ v.pb(i); } } mn=min(mn,w[i]); h[i]=w[i]; } for(i=1;i<=m;i++){ cin>>l>>r>>k; if(k<mn&&v.size()>0){ a=upper_bound(v.begin(),v.end(),l)-v.begin(); if(l<v[a]&&v[a]<=r){ cout<<1<<endl; } else{ cout<<0<<endl; } continue; } c=0; while(c==0){ c=1; for(j=l;j<r;j++){ if(w[j]+w[j+1]<=k&&w[j]>w[j+1]){ c=0; swap(w[j],w[j+1]); } } } c=1; for(j=l;j<r;j++){ if(w[j]>w[j+1]){ c=0; break; } } cout<<c<<endl; for(j=l;j<=r;j++){ w[j]=h[j]; } } }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:12:35: warning: unused variable 'ans' [-Wunused-variable]
   12 |  ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mn=1e9,a;
      |                                   ^~~
sortbooks.cpp:12:43: warning: unused variable 'b' [-Wunused-variable]
   12 |  ll n,m,w[200001],h[200001],l,r,k,ans,i,j,b,c,mn=1e9,a;
      |                                           ^
#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...