ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

P1068 [NOIP2009 普及组] 分数线划定

2022-01-29 15:00:32  阅读:62  来源: 互联网

标签:info int NOIP2009 id P1068 score c2 分数线 c1


// Problem: P1068 [NOIP2009 普及组] 分数线划定
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1068
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// User: Pannnn

#include <bits/stdc++.h>

using namespace std;

struct Candidate {
    int id;
    int score;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    vector<Candidate> info(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> info[i].id >> info[i].score;
    }
    
    sort(info.begin() + 1, info.end(), [](const Candidate &c1, const Candidate &c2) -> bool {
        if (c1.score != c2.score) {
            return c1.score > c2.score;
        } else {
            return c1.id < c2.id;
        }
    });
    
    int line = info[(int)(m * 1.5)].score;
    vector<Candidate> res;
    for (int i = 1; i <= n; ++i) {
        if (info[i].score >= line) {
            res.push_back(info[i]);
        }
    }
    
    cout << line << " " << res.size() << endl;
    for(int i = 0; i < res.size(); ++i) {
        cout << res[i].id << " " << res[i].score << endl;
    }
    return 0;
}

标签:info,int,NOIP2009,id,P1068,score,c2,分数线,c1
来源: https://www.cnblogs.com/pannnn/p/15855085.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有