Submission #498616

#TimeUsernameProblemLanguageResultExecution timeMemory
498616IOI_champion_in_1980Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
3023 ms1400 KiB
#include <bits/stdc++.h> #include <math.h> typedef long long ll; using namespace std; ll i, j, t, a, n, m, b, c, d, f, g; int x[100100], y[100100]; void quickSort(int *array, int low, int high) { int i=low;int j=high;int pivot=array[(i + j)/2];int temp;while(i<=j){while(array[i]<pivot)i++;while(array[j]>pivot)j--; if(i<=j){temp=array[i];array[i]=array[j];array[j]=temp;i++;j--;}}if(j>low)quickSort(array,low,j);if(i<high)quickSort(array,i,high); } int binarySearch(int array[], int x, int low, int high) { while(low<=high){int mid=low+(high-low)/2;if(array[mid]==x)return mid; if(array[mid]<x)low=mid+1;else high=mid-1;}return -1; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>n>>m; for (a=1; a<=n; a++) cin>>x[a]; for (a=1; a<=m; a++) { int l, r, k; cin>>l>>r>>k; int ans=1; for (b=l; b<=r; b++) y[b-l+1]=x[b]; for (b=(r-l)+1; b>=2; b=b-2) { int mmax1=y[b], mmax2=y[b-1]; int p1=b, p2=b-1; int r=0; for (c=b; c>=1; c--) { if (y[c]>mmax1) { r=1; mmax2=mmax1; mmax1=y[c]; p2=p1; p1=c; } } if (y[p1]+y[p2]>k) { ans=0; break; } if (r==0) swap(y[b], y[b-1]); else { swap(y[b], y[p1]); swap(y[b-1], y[p2]); } // for (c=1; c<=n; c++) cout<<y[c]<<" "; // cout<<endl; } cout<<ans<<endl; } } /* */

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:32:20: warning: variable 'mmax2' set but not used [-Wunused-but-set-variable]
   32 |    int mmax1=y[b], mmax2=y[b-1];
      |                    ^~~~~
#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...