题目
kedaOJ#P1530一起摇摆
思路
无
代码
#include<bits/stdc++.h>
int main() {
int n;
std::cin >> n;
std::vector<int> arr1(n);
std::vector<int> arr2(n);
for (int i = 0; i < n; ++i) {
std::cin >> arr1[i];
}
for (int i = 0; i < n; ++i) {
std::cin >> arr2[i];
}
std::vector<int> result;
std::sort(arr1.begin(), arr1.end());
std::sort(arr2.begin(), arr2.end());
for (int i = 0, j = 0; i < n && j < n; ) {
if (arr1[i] == arr2[j]) {
result.push_back(arr1[i]);
i++;
j++;
} else if (arr1[i] < arr2[j]) {
i++;
} else {
j++;
}
}{
int min_val = *result.begin();
std::cout << min_val << std::endl;
}
return 0;
}
标签:kedaOJ,std,P1530,int,++,摇摆,arr2,arr1,result
From: https://www.cnblogs.com/mcr130102/p/18262313