题解
2023-07-07 12:21:52
发布于:上海
89阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct s{
string name;
int jg;
int hy;
}a[100];
bool cmp(s x,s y){
if(x.hy>y.hy) return x.hy>y.hy;
else if(x.hy==y.hy){
if(x.jg>y.jg) return x.jg>y.jg;
return 0;
}return 0;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].jg>>a[i].hy;
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++){
if(a[i].jg<=m){
cout<<a[i].name<<" "<<a[i].jg<<" "<<a[i].hy<<endl;
return 0;
}
}
cout<<"...>_<...";
return 0;
}
全部评论 1
#include <bits/stdc++.h> using namespace std; int n,m,sum = 0,mn1 = 22; struct p{ string b; int c,d; }a[114]; bool cmp(p q,p w){ return q.d > w.d; } int main(){ cin >> n >> m; for(int i = 0;i < n;i ++){ cin >> a[i].b >> a[i].c >> a[i].d; mn1 = min(mn1,a[i].c); } if(m < mn1){ cout << "...>_<..." << endl;; } sort(a,a + n,cmp); for(int i = 0;i < n;i ++){ if(m >= a[i].c){ cout << a[i].b << " " << a[i].c << " " << a[i].d << endl; break; } } return 0; }
2024-08-30 来自 北京
0
有帮助,赞一个