The code prints the same output "NO" every time. Please someone help me with what the error can be.
Code:#include<iostream> using namespace std; int main() { int n,q,i,j; int a,b,c,d; cin >> n >> q; int ar[n]; for(j=0;j<n;j++) { cin >> ar[j]; } for(i=0;i<q;i++) { int l,r; cin >> l >> r; ar[l-1]=a; ar[l]=b; ar[r-2]=c; ar[r-1]=d; if(a<b) { if(c>d) { cout << "YES" << endl; } else { cout << "NO" << endl; } } else { if(c<d) { cout << "YES" << endl; } else { cout << "NO" << endl; } } } return 0; }




Reply With Quote
