C++ 候选人投票获胜问题 - 算法实现与优化
#include
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<vector
vector<int> count(m, 0);
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
count[votes[j][i] - 1]++;
if (count[votes[j][i] - 1] > n / 2) {
cout << votes[j][i] << endl;
cout << i << endl;
return 0;
}
}
}
}
原文地址: https://www.cveoy.top/t/topic/qg6L 著作权归作者所有。请勿转载和采集!