刚开始有点担心超时,但是发现其实可以边输入边攒数据
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int maxn=10100;
int main()
{
int n,ans,total=-1;
int hashnum[maxn]={0};
cin>>n;
for (int i=0;i<n;i++)
{
int team,member,score;
scanf("%d-%d %d",&team,&member,&score);
hashnum[team]+=score;
if (hashnum[team]>total)
{
ans=team;
total=hashnum[team];
}
}
printf("%d %d",ans,total);
}
本文介绍了一段用于比赛成绩统计的C++代码,通过哈希数组实现团队得分累计,最终输出获胜队伍及其总分。代码使用了标准输入输出流、字符串处理及条件判断等技术。
212

被折叠的 条评论
为什么被折叠?



