> 文档中心 > NOIP 2009 普及组 分数线划定

NOIP 2009 普及组 分数线划定

#include using namespace std;int n, m;struct info {int k, s;}a[5009];bool cmp (info x, info y) {if (x.s > y.s) return true;if (x.s == y.s && x.k < y.k) return true;return false;}int main() {cin >> n >> m;m *= 1.5;for (int i = 1; i <= n; i ++) cin >> a[i].k >> a[i].s;sort(a + 1, a + 1 + n, cmp);int cnt = 1;while (cnt < m || a[cnt].s == a[cnt + 1].s) {cnt ++;}cout << a[cnt].s << ' ' << cnt << endl;for (int i = 1; i <= cnt; i ++) {cout << a[i].k << ' ' << a[i].s << endl;}return 0;}