博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Pku3664
阅读量:7159 次
发布时间:2019-06-29

本文共 1911 字,大约阅读时间需要 6 分钟。

/*D - Election TimeTime Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64uSubmitStatusDescriptionThe cows are having their first election after overthrowing the tyrannical Farmer John, and Bessie is one of N cows (1 ¡Ü N ¡Ü 50,000) running for President. Before the election actually happens, however, Bessie wants to determine who has the best chance of winning.The election consists of two rounds. In the first round, the K cows (1 ¡Ü K ¡Ü N) cows with the most votes advance to the second round. In the second round, the cow with the most votes becomes President.Given that cow i expects to get Ai votes (1 ¡Ü Ai ¡Ü 1,000,000,000) in the first round and Bi votes (1 ¡Ü Bi ¡Ü 1,000,000,000) in the second round (if he or she makes it), determine which cow is expected to win the election. Happily for you, no vote count appears twice in the Ai list; likewise, no vote count appears twice in the Bi list.Input* Line 1: Two space-separated integers: N and K* Lines 2..N+1: Line i+1 contains two space-separated integers: Ai and BiOutput* Line 1: The index of the cow that is expected to win the election.Sample Input5 33 109 25 68 46 5Sample Output5BY Grant Yuan2014.7.11*/#include
#include
#include
#include
using namespace std;int m,k;typedef struct{long long f;long long s;int m;}vote;vote v[50001];void Qsort(vote a[],int left,int right){ int key=a[left].f,i=left,j=right+1,t,l; if(left
key); if(i>=j)break; t=a[j].f; a[j].f=a[i].f;a[i].f=t; t=a[j].s; a[j].s=a[i].s;a[i].s=t; t=a[j].m; a[j].m=a[i].m;a[i].m=t; } t=a[left].f;a[left].f=a[j].f;a[j].f=t; t=a[left].s;a[left].s=a[j].s;a[j].s=t; t=a[left].m;a[left].m=a[j].m;a[j].m=t; Qsort(a,left,i-1); Qsort(a,i+1,right);}}int main(){ int max; cin>>m>>k; for(int i=0;i
>v[i].f>>v[i].s; v[i].m=i;} Qsort(v,0,m); max=0; for(int i=1;i
v[max].s) max=i; cout<
<

转载地址:http://yvegl.baihongyu.com/

你可能感兴趣的文章
Oracle sequence 简单的使用
查看>>
如何做到独特的营销价值
查看>>
APMserv5.2.6 apache启动失败
查看>>
UICollectionView简单使用
查看>>
Eclipse for Mac 常用快捷键整理
查看>>
webservice之接口开发
查看>>
MySQL的安装及基本操作
查看>>
走过那段路
查看>>
利用ISA2006发布Exchange的RPC over HTTPS
查看>>
ifconfig命令--Linux命令应用大词典729个命令解读
查看>>
我的友情链接
查看>>
IOS 点击空白处隐藏键盘的几种方法
查看>>
如何拿到国内IT巨头的Offer
查看>>
CentOS 7.3 配置postfix并发送邮件
查看>>
border和background
查看>>
TCP/IP之(三)四次挥手
查看>>
设计模式之工厂模式(三)
查看>>
【木叶精品系统】木叶 GhostXP SP3 纯净版/装机版_2013.06
查看>>
spring标签的使用
查看>>
Record log while in programing
查看>>