【poj解题】3664
简单,两次排序
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #define MAX 50000 struct 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;
}
【poj解题】3664的更多相关文章
- POJ解题经验交流
感谢范意凯.陈申奥.庞可.杭业晟.王飞飏.周俊豪.沈逸轩等同学的收集整理. 题号:1003 Hangover求1/2+1/3+...1/n的和,问需多少项的和能超过给定的值 类似于Zerojudg ...
- 【poj解题】1028
stack的应用 #include<iostream> #include<stack> #include<stdio.h> #include<stdlib.h ...
- 【poj解题】3663
排序, 遍历,需要裁减 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX ...
- 【poj解题】1308
判断一个图是否是一个树,树满足一下2个条件即可:1. 边树比node数少12. 所有node的入度非0即1 节点数是0的时候,空树,合法树~ 代码如下 #include <stdio.h> ...
- [poj解题]1017
Packets Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41014 Accepted: 13776 Descrip ...
- 洛谷 P1731 [NOI1999]生日蛋糕 && POJ 1190 生日蛋糕
题目传送门(洛谷) OR 题目传送门(POJ) 解题思路: 一道搜索题,暴力思路比较容易想出来,但是这道题不剪枝肯定会TLE.所以这道题难点在于如何剪枝. 1.如果当前状态答案已经比我们以前某个状态 ...
- 网络-05-端口号-F5-负载均衡设-linux端口详解大全--TCP注册端口号大全备
[root@test1:Standby] config # [root@test1:Standby] config # [root@test1:Standby] config # [root@test ...
- POJ 1003 解题报告
1.问题描述: http://poj.org/problem?id=1003 2.解题思路: 最直观的的想法是看能不能够直接求出一个通项式,然后直接算就好了, 但是这样好水的样子,而且也不知道这个通项 ...
- POJ 1004 解题报告
1.题目描述: http://poj.org/problem?id=1004 2.解题过程 这个题目咋一看很简单,虽然最终要解出来的确也不难,但是还是稍微有些小把戏在里面,其中最大的把戏就是float ...
随机推荐
- python3.5 + django1.9.1+mysql
python3 对mysql 的驱动不再是mysqldb 具体步骤 : 1 安装依赖 pip install PyMySQL 2 修改配置 __init__.py import pymysql pym ...
- 解析JSON对象与字符串之间的相互转换
在开发的过程中,如果对于少量参数的前后台传递,可以直接采用ajax的data函数,按json格式传递,后台Request即可,但有的时候,需要传递多个参数,这样后台 接受的时候Request多个很麻烦 ...
- [转]Zend Studio 文件头和方法注释设置
在zend studio ide 7.1 中选择窗口->首选项->PHP–>编辑器 –>模板 –>新建然后添加 funinfo或fileinfo 模板代码根据下边定义的C ...
- caffe的matlab接口一览表
blob 简述 方法: shape reshape get_diff set_diff 私有方法: check_and_preprocess_shape check_and_preprocess_da ...
- Let'sencrypt认证的网站Https配置
推荐使用这个脚本,具体说明里面都有 https://github.com/xdtianyu/scripts/tree/master/le-dns 它是通过调用dns服务商的api更新txt记录实现,无 ...
- C#中的Virtual、Override和new关键词理解
来源:http://blog.csdn.net/jackiezhw/article/details/2673992 在 C# 中,派生类可以包含与基类方法同名的方法. 基类方法必须定义为 virtua ...
- myeclipse 调试JSP页面
http://jingyan.baidu.com/article/636f38bb1ef1aad6b9461048.html
- ExceL转PDF
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Excel = ...
- WNDCLASS 窗口类结构
Windows 的窗口总是基于窗口类来创建的,窗口类同时确定了处理窗口消息的窗口过程(回调函数). 在创建应用程序窗口之前,必须调用 RegisterClass 函数来注册窗口类.该函数只需要一个参数 ...
- OpenGL ES之glUniform函数
函数名: glUniform 功能: 为当前程序对象指定Uniform变量的值.(译者注:注意,由于OpenGL ES由C语言编写,但是C语言不支持函数的重载,所以会有很多名字相同后缀不同的函数版本存 ...