Design Tutorial: Learn from Life
Codeforces Round #270 B:http://codeforces.com/contest/472/problem/B
题意:n个人在1楼,想要做电梯上楼,只有1个电梯,每次只能运k个人,每移动一层需要1秒。问最小的是时间把所有人送到想去的楼层。
题解:贪心,每次选择楼层数最大k个人,用优先队列维护一下即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
const int N=;
int n,k,temp;
int main(){
scanf("%d%d",&n,&k);
priority_queue<int>Q;
for(int i=;i<=n;i++){
scanf("%d",&temp);
Q.push(temp);
}
int ans=,tt=k;
while(Q.size()>k){
tt=k;
ans+=(Q.top()-);
while(tt--)
Q.pop();
}
if(Q.size()>)
ans+=(Q.top()-);
printf("%d\n",ans*);
}
Design Tutorial: Learn from Life的更多相关文章
- cf472B Design Tutorial: Learn from Life
B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes ...
- cf472A Design Tutorial: Learn from Math
A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...
- Codeforces Round #270--B. Design Tutorial: Learn from Life
Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes in ...
- Codeforces Round #270 A. Design Tutorial: Learn from Math【数论/埃氏筛法】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- A - Design Tutorial: Learn from Math(哥德巴赫猜想)
Problem description One way to create a task is to learn from math. You can generate some random mat ...
- codeforces B. Design Tutorial: Learn from Life
题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间.... 这是一道神题啊,自己的思路不知不觉的就按 ...
- codeforce A. Design Tutorial: Learn from Math
题意:将一个数拆成两个合数的和, 输出这两个数!(这道题做的真是TMD水啊)开始的时候不知道composite numbers是啥意思,看了3遍才看懂.... 看懂之后又想用素数筛选法来做,后来决定单 ...
- 【CodeForces 472A】Design Tutorial: Learn from Math
题 题意:给你一个大于等于12的数,要你用两个合数表示出来.//合数指自然数中除了能被1和本身整除外,还能被其他的数整除(不包括0)的数. 分析:我们知道偶数除了2都是合数,给你一个偶数,你减去一个偶 ...
- codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)
题目链接:http://www.codeforces.com/problemset/problem/472/A题意:给你一个数n,将n表示为两个合数(即非素数)的和.C++代码: #include & ...
随机推荐
- hdu 1095 A+B for Input-Output Practice (VII)
A+B for Input-Output Practice (VII) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32 ...
- 【转】monkeyrunner学习总结二:连接、安装、启动
一.获取packageName与startActivity 前置条件:已成功安装配置SL4A并连接PC调试(参见:monkeyrunner学习总结一:环境搭建:http://www.amsoft.cn ...
- orale做报表常用函数和表达式的总结
最近一段时间连续的做了几十张报表,通过原生sql对数据进行分析 ,也算是有了一定的了解,发现其中一些函数和表达式使用频率较高,现总结如下: (1).round()函数 round函数说白了就是把一 ...
- Memcached 工作原理
http://hzp.iteye.com/blog/1872664 Memcached处理的原子是每一个(key,value)对(以下简称kv对),key会通过一个hash算法转化成hash-key, ...
- 几种RAID技术比较
http://book.51cto.com/art/201310/412862.htm RAID(廉价磁盘冗余阵列)技术主要是为了改善磁盘的访问延迟,增强磁盘的可用性和容错能力.目前服务器级别的计算机 ...
- 安装Numpy和matplotlib
(1)测试程序 这是我从网上(http://www.open-open.com/lib/view/open1393488232380.html)找到的一个使用Numpy和matplotlib的 ...
- Markdown 生成目录
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.2/styles/googlecode.mi ...
- Requirejs开篇
前言 随着页面的内容丰富,以及网站体验更好.性能优化等,原有的通过script标签引入JavaScript脚本的方式已经不能很好地解决,此时新的一种JavaScript加载方式产生了--延时加载.执行 ...
- 2016/01/19 javascript学习笔记-name属性
1. name属性只在少数html元素中有效:包括表单.表单元素.<iframe>和<img>元素. 基于name属性的值选取html元素,可以使用document对象的get ...
- 禁用Linux bash rm --force
防止无意的Linux bash rm --force 二.禁用rm -rf 因为rm -rf 删除文件的时候,经常会不小心将系统文件或者多个有用的目录删除掉.有两种方法:1,每次删除都用-i(inte ...