博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【poj解题】3664
阅读量:7028 次
发布时间:2019-06-28

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

简单,两次排序

#include 
#include
#include
#define MAX 50000struct Vote { int index; int a; int b;};struct Vote candidates[MAX];int N, K;int cmp_1(const void * a, const void * b) { return ((struct Vote *)b)->a - ((struct Vote *)a)->a; }int cmp_2(const void * a, const void * b) { return ((struct Vote *)b)->b - ((struct Vote *)a)->b; }int pick() { qsort(candidates, N, sizeof(candidates[0]), cmp_1); qsort(candidates, K, sizeof(candidates[0]), cmp_2); return candidates[0].index;}int main() { int i; int res; scanf("%d%d", &N, &K); for(i = 0; i < N; i++) { scanf("%d%d", &candidates[i].a, &candidates[i].b); candidates[i].index = i + 1; } res = pick(); printf("%d\n", res); return 0;}

  

转载于:https://www.cnblogs.com/igloo1986/p/3535029.html

你可能感兴趣的文章
记Promise得一些API
查看>>
javascript事件之调整大小(resize)事件
查看>>
当模板字符串中出现#号时,可以使用双反斜杠进行转义
查看>>
Spring 教程(一) 概述
查看>>
python读取txt文件以空行作为数据的切分处理
查看>>
【2012百度之星资格赛】I:地图的省钱计划
查看>>
boost::bind的使用
查看>>
SQL inner join、left join、right join用法
查看>>
Daily scrum[2013.12.05]
查看>>
WebLogic11g-常用运维操作
查看>>
71.Ext.form.ComboBox 完整属性
查看>>
Python内置的服务器的使用
查看>>
try/catch/finally语句
查看>>
关于refs/for/ 和refs/heads/
查看>>
1005. 继续(3n+1)猜想 (25)
查看>>
Python的魔法方法 .
查看>>
iOS 在当前控制器中发送短信
查看>>
1158: 零起点学算法65——进制转换
查看>>
音频 PCM 数据的采集和播放
查看>>
《大话设计模式》读书笔记-第14章 观察者模式
查看>>