https://www.acmicpc.net/problem/15366
๋ฌธ์
Harry Potter has damaged his magic wand in a fight with Lord Voldemort. He has decided to get a new wand in Olivander's wand shop. On the floor of the shop, he saw N wands and N wand boxes. The lengths of the wands are, respectively, X1, X2, ...Xn, and the box sizes are Y1,Y2, ...Yn. A wand of length X can be placed in a box of size Y if X ≤ Y. Harry wants to know if he can place all the wands in boxes so that each box contains exactly one wand. Help him solve this difficult problem.
์ ๋ ฅ
The first line of input contains the positive integer N (1 ≤ N ≤ 100), the number from the task.
The second line contains N positive integers Xi (1 ≤ Xi ≤ 109), the numbers from the task.
The third line contains N positive integers Yi (1 ≤ Yi ≤ 109), the numbers from the task.
์ถ๋ ฅ
If Harry can place all the wands in boxes, output “DA” (Croatian for yes), otherwise output “NE” (Croatian for no).
ํด์ค
ํ์ด
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
int x[n], y[n];
for(int i=0; i<n; i++){
cin >> x[i];
}
for(int i=0; i<n; i++){
cin >> y[i];
}
sort(x, x+n);
sort(y, y+n);
for(int i=0; i<n; i++){
if(x[i] > y[i]){
cout << "NE";
return 0;
}
}
cout << "DA";
return 0;
}
'๐ฆ Chango > ๐ฃ EDOC' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ][C++] 13458๋ฒ: ์ํ ๊ฐ๋ (0) | 2021.09.06 |
---|---|
[BOJ][C++] ๋ฐฑ์ค 1259๋ฒ: ํฐ๋ฆฐ๋๋กฌ์ (0) | 2021.09.06 |
[C++][BOJ] ๋ฐฑ์ค 6997๋ฒ: Guessing Game 1 (0) | 2021.08.25 |
[Android Studio / Kotlin] ์ฝํ๋ฆฐ๊ณผ ๋ฆฌ์คํธ๋ทฐ (List View) (0) | 2021.05.02 |
[Android Studio / Kotlin] ์ค์ ์ฑ๊ฐ๋ฐ์์ ์ฌ์ฉํ ์ฝํ๋ฆฐ๋ง ๋ชจ์๋ณด๊ธฐ (๊ธฐ๋ณธ) (0) | 2021.05.02 |