洛谷缓冲区占两个字符
评测环境不同 测试数据可能是在Windows里做的 换行符在Linux里变成了两个字符
https://www.luogu.com.cn/problem/P5740#submit
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;
using ll = long long int;
string str[1200];
int main()
{
int n;
cin >> n;
getchar();
getchar(); //这里
int max_ = -1;
int pos = -1;
for(int i = 0 ; i < n ; i ++)
{
getline(cin,str[i]);
string ch;
int a ,b , c;
stringstream ssin(str[i]);
ssin>>ch>>a>>b>>c;
//cout << a+b+c<<' ';
if((a+b+c)>max_)
{
max_ = a+b+c;
pos = i;
}
}
str[pos].pop_back();
cout << str[pos];
return 0;
}
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;
using ll = long long int;
int main()
{
int n;
cin >> n;
int max_ = 0;
int pos = 0;
string name[n];
int s1[n] , s2[n] , s3[n];
for(int i = 0 ; i < n ; i++)
{
cin >> name[i]>>s1[i]>>s2[i]>>s3[i];
if((s1[i]+s2[i]+s3[i])>max_)
{
max_ = s1[i]+s2[i]+s3[i];
pos = i;
}
}
cout << name[pos]<<' '<<s1[pos]<<' '<<s2[pos]<<' '<<s3[pos];
return 0;
}