题解
2023-08-17 14:02:31
发布于:广东
5阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> income(n);
for (int i = 0; i < n; i++) {
cin >> income[i];
}
vector<int> ex(n);
for (int i = 0; i < n; i++) {
cin >> ex[i];
}
unordered_map<int, int> profitCount;
for (int i = 0; i < n; i++) {
int profit = income[i] - ex[i];
profitCount[profit]++;
}
vector<pair<int, int>> sortedProfitCount;
for (auto it = profitCount.begin(); it != profitCount.end(); ++it) {
sortedProfitCount.push_back(make_pair(it->first, it->second));
}
sort(sortedProfitCount.begin(), sortedProfitCount.end());
for (const auto& p : sortedProfitCount) {
cout << p.first << " " << p.second << endl;
}
return 0;
}
英语
这里空空如也
有帮助,赞一个