forked from opencodeiiita/CodeDigger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opencodeiiita#136 from kalim-Asim/main
task3 solved
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
#define MOD 1000000007 | ||
#define int long long int | ||
#define pb push_back | ||
#define MAX LLONG_MAX | ||
#define MIN LLONG_MIN | ||
#define vi vector<int> | ||
#define mii map<int, int> | ||
#define pii pair<int, int> | ||
#define no cout << "NO\n" | ||
#define yes cout << "YES\n" | ||
#define sz(x) ((int)(x).size()) | ||
#define all(x) (x).begin(), (x).end() | ||
#define vin(a) for(int i = 0; i < (a).size(); ++i) cin >> a[i]; | ||
#define vout(a) for(int i = 0; i < (a).size(); ++i) cout << a[i] << ' '; | ||
|
||
void solve() { | ||
int n, x; | ||
cin >> n >> x; | ||
vi a(n); | ||
vin(a); | ||
vi v(a); | ||
sort(all(v)); | ||
bool ans = 1; | ||
if (x >= n && !is_sorted(all(a))) | ||
ans = 0; | ||
|
||
for(int i = n - x; i < x; i++) | ||
ans &= v[i] == a[i]; | ||
|
||
if (ans) yes; | ||
else no; | ||
} | ||
|
||
signed main() { | ||
int t = 1; | ||
// cin >> t; | ||
while (t--) solve(); | ||
return 0; | ||
} |