- 문제 링크 : boj.kr/32752
- 난이도 : S5
- 태그 : 정렬
코드
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define INF 0x7FFFFFFF
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, l, r;
cin >> n >> l >> r;
vector<int> arr(n);
for(auto &e : arr) cin >> e;
sort(arr.begin()+l-1, arr.begin()+r);
int ans = 1;
for(int i = 1; i < n; i++) {
ans &= arr[i] >= arr[i-1];
}
cout << ans;
return 0;
}
풀이
해당하는 범위만 정렬한 뒤 전체 수열이 단조증가인지 확인한다.
728x90
'PS' 카테고리의 다른 글
BOJ 31738 : 매우 어려운 문제 (0) | 2025.01.07 |
---|---|
BOJ 32932 : 드론 조작 (1) | 2025.01.06 |
BOJ 31908 : 커플링 매치 (1) | 2025.01.04 |
BOJ 10799 : 쇠막대기 (0) | 2025.01.03 |
BOJ 28136 : 원, 탁! (0) | 2025.01.02 |