Skip to content

A. Halloumi Boxes (CF1903 800 RATED)

Published:

Table of contents

Open Table of contents

Approach

If k>1 or else array is already sorted then it’s YES else NO.

Code Implementation

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    cin >> t;

    while (t--) {
    	int n,k;
    	cin >> n >> k;
    	int arr[n];
    	for(int i=0; i<n; i++) {
    		cin >> arr[i];
    	}
    	if (is_sorted(arr, arr+n) || k>1)
    		cout << "YES" << endl;
    	else
    		cout << "NO" << endl;
        }

    return 0;   
}

Previous Post
A. Line Trip (CF1901 800 RATED)
Next Post
A. Consecutive Sum Riddle (CF1594 800 RATED)