社区讨论
20分求助 只过了前2个点!
P1068[NOIP 2009 普及组] 分数线划定参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @lo13x179
- 此快照首次捕获于
- 2023/10/22 14:47 2 年前
- 此快照最后确认于
- 2023/11/02 14:18 2 年前
CPP
#include<iostream>
#include<cmath>
using namespace std;
struct people
{
int x;
int score;
}a[10010],b[100010];
void maopao_sort(people a[], int n)
{
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n - i; j++)
{
if (a[j].score > a[j + 1].score)
{
swap(a[j].score, a[j + 1].score);
swap(a[j].x, a[j + 1].x);
}
}
}
}
int n, m;
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i].x >> a[i].score;
maopao_sort(a, n);
int s = floor(m * 1.5);
int k = a[n-s+1].score;
int t;
for (int i = n; i >=1; i--)
{
if (a[i].score == a[i -1].score && a[i].x > a[i -1].x)
{
swap(a[i].x, a[i -1].x);
}
}
cout << k << " ";
int num = 0;
for (int i = n; i >= 1; i--)
{
if (a[i].score >= k)
num++;
}
cout << num << endl;
for (int i = n; i >= 1; i--)
{
if (a[i].score >= k)
{
cout << a[i].x << " " << a[i].score << endl;
}
}
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...