zoukankan      html  css  js  c++  java
  • P1068 分数线划定

    题目地址


    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cmath>
    #include<vector>
    using namespace std;
    const int MAXN=1e4;
    struct Person{
    	int index,score;
    	bool operator <(Person another)const{
    		return score==another.score?index<another.index:score>another.score;
    	}
    }persons[MAXN];
    vector<Person> ans;
    int main(){
    	int n,m;
    	scanf("%d%d",&n,&m);
    	for(int i=1;i<=n;i++){
    		scanf("%d%d",&persons[i].index,&persons[i].score);
    	}
    	sort(persons+1,persons+n+1);
    	int cnt=floor(m*1.5);
    	int lastScore=0;
    	for(int i=1;i<=n;i++){
    		int nowScore=persons[i].score;
    		if(lastScore==nowScore){
    			ans.push_back(persons[i]);
    			continue;
    		}else{
    			if(i>cnt)break;
    			ans.push_back(persons[i]);
    			lastScore=nowScore;
    		}
    	}
    	printf("%d %d
    ",lastScore,ans.size());
    	for(int i=0;i<ans.size();i++){
    		printf("%d %d
    ",ans[i].index,ans[i].score);
    	}
    	return 0;
    }
  • 相关阅读:
    redis
    libevent简述
    IPC-本地套接字
    广播和组播
    UDP实现并发服务器
    select
    epoll
    BUUCTF-[极客大挑战 2019]HardSQL 1
    CTFHUB-Injection V2.0
    SQL注入中登录框只验证用户名情况下的绕过
  • 原文地址:https://www.cnblogs.com/zbsy-wwx/p/11680515.html
Copyright © 2011-2022 走看看