-
Notifications
You must be signed in to change notification settings - Fork 0
/
same.cpp
49 lines (47 loc) · 1.14 KB
/
same.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
int N, i;
cin >> N;
int A[N], B[N];
for (i = 0; i < N; ++i) cin >> A[i];
for (i = 0; i < N; ++i) cin >> B[i];
int j;
int counter = 0;
std::sort(A, A+N);
std::sort(B, B+N);
for (i = 0; i < N; ++i){
if (A[i] == B[i]) counter++;
}
if (counter == N) cout<<"yes"<<endl;
else {
int min, max;
if (A[0] != B[0]) {
if (A[0] < B[0]) min=A[0];
else min=B[0];
}
else if (A[0] == B[0]) {
i = 1;
if (A[i] == B[i]) {
while (A[i] == B[i]) i++;
}
if (A[i] < B[i]) min=A[i];
else min=B[i];
}
if (A[N-1] != B[N-1]) {
if (A[N-1] > B[N-1]) max=A[N-1];
else max=B[N-1];
}
else if (A[N-1] == B[N-1]) {
i = N - 2;
if (A[i] == B[i]) {
while(A[i] == B[i]) --i;
}
if (A[i] > B[i]) max=A[i];
else max=B[i];
}
cout << "no" << ' ' << min << ' ' << max << endl;
}
return 0;
}