Submission #498677

#TimeUsernameProblemLanguageResultExecution timeMemory
498677IOI_champion_in_1980Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
0 / 100
3077 ms8172 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[1000100], y[1000100]; 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-1], mmax2=y[b]; int p1=b-1, p2=b; // int r=0; for (c=b; c>=1; c--) { if (y[c]>mmax1) { // r=1; mmax2=mmax1; mmax1=y[c]; p2=p1; p1=c; } } // for (c=1; c<=n; c++) cout<<y[c]<<" "; // cout<<endl; if (p1==b-1 and p2==b and y[b]>=y[b-1]) { b++; continue; } if (y[p1]+y[p2]>k) { ans=0; break; } 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:22: warning: variable 'mmax2' set but not used [-Wunused-but-set-variable]
   32 |    int mmax1=y[b-1], mmax2=y[b];
      |                      ^~~~~
#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...