4 条题解
-
2
#include <iostream> #include <cstring> using namespace std; int main() { int n, k=0; cin >> n; string name[n]; int score[n][4]; for (int i=0; i<n; ++i) cin >> name[i] >> score[i][0] >> score[i][1] >> score[i][2]; for (int i=0; i<n; ++i) score[i][3] = score[i][0] + score[i][1] + score[i][2]; for (int i=1; i<n; ++i) if (score[i][3] > score[k][3]) k = i; cout << name[k] << ' ' << score[k][0] << ' ' << score[k][1] << ' ' << score[k][2] << endl; return 0; }
-
0
#include<bits/stdc++.h> using namespace std; int n; struct s{ int y; int s; int e; int h; string name; }a[1001],ans; int main(){ cin>>n; ans.y=ans.s=ans.e=0; for(int i=1;i<=n;i++){ cin>>a[i].name>>a[i].y>>a[i].s>>a[i].e; a[i].h=a[i].y+a[i].s+a[i].e; ans.h=ans.y+ans.s+ans.e; if(a[i].h>ans.h)ans=a[i]; } cout<<ans.name<<" "<<ans.y<<" "<<ans.s<<" "<<ans.e; return 0; }
-
0
#include<bits/stdc++.h> using namespace std; struct stu{ string name; int ch; int ma; int en; }a[1005],ans; int main(){ int n; cin>>n; ans.ch=-10,ans.ma=-10,ans.en=-10; for(int i=1;i<=n;i++){ cin>>a[i].name>>a[i].ch>>a[i].ma>>a[i].en; if((a[i].ch+a[i].ma+a[i].en)>(ans.ch+ans.ma+ans.en)){ ans = a[i]; } } cout<<ans.name<<" "<<ans.ch<<" "<<ans.ma<<" "<<ans.en; return 0; }
-
0
PYTHON代码(python)
import functools n = int(input()) result = [] for i in range(n): parts = input().split(' ') name = parts[0] yw = int(parts[1]) sx = int(parts[2]) yy = int(parts[3]) result.append([name,yw,sx,yy,i+1]) def my_cmp(a,b): if a[1]+a[2]+a[3] == b[1]+b[2]+b[3]: if a[4]>b[4]: return 1 else: return -1 else: if a[1]+a[2]+a[3] < b[1]+b[2]+b[3]: return 1 else: return -1 result.sort(key=functools.cmp_to_key(my_cmp)) for i in range(4): print(result[0][i],end=' ')
- 1
信息
- ID
- 2031
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- (无)
- 递交数
- 236
- 已通过
- 98
- 上传者