acgo题库
  • 首页
  • 题库
  • 学习
  • 天梯
  • 备赛

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
  • 竞赛
  • 讨论
  • 团队
登录
注册
题目详情提交记录(0)
  • 加油💪

    #include<bits/stdc++.h> #include <map> using namespace std; map<int, int> mp; int t; int main(){ cin >> t; while(t--){ mp.clear();//清空 int n; cin >> n; int ans = 0; for(int i = 1; i <= n; i++){ int num; cin >> num; mp[num]; if(mp[num] > ans){ ans = mp[num]; } } int cnt = 0; for(auto it = mp.begin(); it!=mp.end();it){ if(ans == (it->second)){//如果与最大相同 cnt++; } } //如果所有人票数一样 if(mp.size() == cnt){ cout << "-1"; }else{ //输出票数最大的人 cout << cnt << endl; for(auto it = mp.begin(); it!=mp.end();it++){ if(ans == (it->second)){//如果与最大相同 cout << it->first << " "; } } } cout << endl; }

    userId_undefined

    汤汤汤汤圆

    倔强青铜
    2阅读
    0回复
    0点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页