按字典序对两个序列进行比较。
输入
- 第一行输入一个n。代表第一个序列A的元素个数。
n
- 接下来一行输入A序列。
a0,a1,...,an−1 - 第三行输入一个m。代表第二个序列B的元素个数。
m
- 接下来一行输入B序列。
b0,b1,...,bn−1
其中
1<=n,m<=1,000
0<=ai,bi<=1,000
输出
如果B比A大,输出1;否则,输出0。
input_01
4
5 4 7 0
5
1 2 3 4 5
output_01
0
input_02
3
1 1 2
4
1 1 2 2
output_02
1
输入样例
3 1 2 3 2 2 4
输出样例
1
提示:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; i++) {
cin >> A[i];
}
cin >> m;
vector<int> B(m);
for (int i = 0; i < m; i++) {
cin >> B[i];
}
if (B > A) {
cout << 1 << endl;
} else {
cout << 0 << endl;
}
return 0;
}