竞赛
考级
回来看看
#include <iostream> #include <vector> #include <algorithm> using namespace std; // 定义一个结构体来存储玩家信息 struct Player { int index; // 玩家序号 int oneStar; // 1星英雄数量 int twoStar; // 2星英雄数量 int threeStar; // 3星英雄数量 int strength; // 阵容强度 }; // 计算阵容强度 int calculateStrength(int oneStar, int twoStar, int threeStar) { return oneStar + twoStar * 3 + threeStar * 9; } // 按照阵容强度排序的比较函数 bool comparePlayers(const Player &a, const Player &b) { if (a.strength != b.strength) { return a.strength > b.strength; // 强度大的在前 } else { return a.index < b.index; // 强度相同,序号小的在前 } } int main() { int n; cin >> n; }
AC狗(=—=)
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<pair<int,int>>p(n); for(int i=0; i<n; ++i) { int a,b,c; cin>>a>>b>>c; p[i]={-(a+3b+9c),i+1}; } sort(p.begin(),p.end()); for(auto& p:p)cout<<p.second<<" "; }//简简单单~~
黑客