1047 编程团体赛 (C++)
2021/11/10 11:09:37
本文主要是介绍1047 编程团体赛 (C++),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
编程团体赛的规则为:每个参赛队由若干队员组成;所有队员独立比赛;参赛队的成绩为所有队员的成绩和;成绩最高的队获胜。
现给定所有队员的比赛成绩,请你编写程序找出冠军队。
输入格式:
输入第一行给出一个正整数 N(≤104),即所有参赛队员总数。随后 N 行,每行给出一位队员的成绩,格式为:队伍编号-队员编号 成绩
,其中队伍编号
为 1 到 1000 的正整数,队员编号
为 1 到 10 的正整数,成绩
为 0 到 100 的整数。
输出格式:
在一行中输出冠军队的编号和总成绩,其间以一个空格分隔。注意:题目保证冠军队是唯一的。
输入样例:
6 3-10 99 11-5 87 102-1 0 102-3 100 11-9 89 3-2 61
结尾无空行
输出样例:
11 176
结尾无空行
代码:
#define _CRT_SECURE_NO_DEPRECATE #include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <string> #include <cmath> #include <numeric> #include <deque> #include <map> using namespace std; int main() { int n; cin >> n; int ans[10050] = { 0 }; while (n--) { int team, person, gride; scanf("%d-%d %d", &team, &person, &gride); ans[team] = ans[team] + gride; } int index = 0; int max_value = *max_element(ans, ans + sizeof(ans) / sizeof(ans[0])); for (int i = 0; i < sizeof(ans) / sizeof(ans[0]); i++) { if (ans[i] == max_value) { index = i; break; } } cout << index << " " << max_value << endl; }
这篇关于1047 编程团体赛 (C++)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-17zero-shot-learning-definition-examples-comparison
- 2024-06-06Package Easy(基于 NSIS 的打包exe安装包工具)使用方法-icode9专业技术文章分享
- 2024-06-06基于 casdoor 的 ELK 开源登录认证解决方案: elk-auth-casdoor-icode9专业技术文章分享
- 2024-05-29Elasticsearch慢查询日志配置
- 2024-05-29揭秘华为如此多成功项目的产品关键——Charter模板
- 2024-05-29海外IDC业务拓展的7大挑战
- 2024-05-29InLine Chat功能优化对标Github Copilot,CodeGeeX带来更高效、更直观的编程体验!
- 2024-05-29CodeGeeX 智能编程助手 6 项功能升级,在Visual Studio插件市场霸榜2周!
- 2024-05-29AutoMQ 生态集成 Apache Doris
- 2024-05-292024年IDC行业的深度挖掘:机遇、挑战与未来展望