0

# include<iostream>

using namespace std;

struct Person
{
int number;
int score;
};

struct Person person[5001];

int main()
{
int n,m;

``````int total;

cin >> n >> m;
total = (int) (m*1.5 + 0.5);
for(int i = 1; i <= n; i++)
cin >> 	person[i].number >> person[i].score;
for(int i = 1; i <= n-1; i++)
for(int j = 1; j <= n-i; j++)
{
struct Person temp;
if(person[j].score < person[j + 1].score)
{
temp = person[j];
person[j] = person[j + 1];
person[j + 1] = temp;
}
if(person[j].score == person[j + 1].score && person[j].number > person[j + 1].number )
{
temp = person[j];
person[j] = person[j + 1];
person[j + 1] = temp;
}

}

cout << person[total].score << " " << total << endl;

for(int i = 1; i <= total; i++)
cout << person[i].number << " " << person[i].score << endl;
return 0;
``````

}

goalltheway | 初学一级 | 园豆：121

0

Conan-jine | 小虾三级 |园豆：1271 | 2020-08-06 16:12
```#include<iostream>
using namespace std;

struct Person
{
int number;
int score;
};

struct Person person[5001];

int main()
{
int n,m;

int total;

cin >> n >> m;
total = int(m*1.5);      //this time doesn't wrong
for(int i = 1; i <= n; i++)
cin >>     person[i].number >> person[i].score;
for(int i = 1; i <= n-1; i++)
for(int j = 1; j <= n-i; j++)
{
struct Person temp;
if(person[j].score < person[j + 1].score)
{
temp = person[j];
person[j] = person[j + 1];
person[j + 1] = temp;
}
if(person[j].score == person[j + 1].score && person[j].number > person[j + 1].number )
{
temp = person[j];
person[j] = person[j + 1];
person[j + 1] = temp;
}

}

//look here!
while(person[total].score==person[total+1].score)   total++;

cout << person[total].score << " " << total << endl;

for(int i = 1; i <= total; i++)
cout << person[i].number << " " << person[i].score << endl;
return 0;
}```
Conan-jine | 园豆：1271 (小虾三级) | 2020-08-06 16:27

perfect

Conan-jine | 园豆：1271 (小虾三级) | 2020-08-06 16:29

goalltheway | 园豆：121 (初学一级) | 2020-08-06 19:53

@goalltheway: 你理解的向下取整理解错了，向下取整的意思是4.5-》4

Conan-jine | 园豆：1271 (小虾三级) | 2020-08-07 11:35

@Conan-jine: 噗。。好吧。谢谢！

goalltheway | 园豆：121 (初学一级) | 2020-08-07 11:36

0

Drophair | 园豆：228 (菜鸟二级) | 2020-08-08 10:13

您需要登录以后才能回答，未注册用户请先注册