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 & ...
随机推荐
- PHP生成HTML页面顶部出现空白部分(字符?)
参考了:PHP生成HTML页面顶部出现空白部分(#65279字符?)的解决办法 查看拼接两个Html,查看文件格式是否是UTF-8 无Bom,我的内容Html是UTF-8 + Bom.
- GestureDetector类及其用法
转载子:http://www.cnblogs.com/rayray/p/3422734.html 项目中有需求:针对一个imageview,点击需要查看大图,左右滑动能执行翻页. 自己对手势这一块并不 ...
- Javascript中函数调用和this的关系
例子先行: var myObject={ foo:"bar", func:function(){ var self=this; console.log("outerfun ...
- sorted函数
我们需要对List.Dict进行排序,Python提供了两个方法对给定的List L进行排序,方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用built-in函数so ...
- ubuntu中安装monodevelop
sudo apt-get install monoDevelop sudo apt-get install build-essentialsudo apt-get install mono-devel ...
- 三分钟学会CSS3中的FLEXBOX布局
原文地址,保护版权,请勿转载:http://page.factj.com/blog/p/2574 这篇文章里我们将学习CSS里flexbox布局的几个最重要的概念,通过学习flexbox布局,你会发现 ...
- How do I create an installation log?
Quote from: http://www.advancedinstaller.com/user-guide/qa-log.html Windows Installer logging Window ...
- 第二章 Qt常用工具的介绍
第二章 Qt常用工具的介绍 (1)No.1 qmake 相信编写过Makefile的开发人员,随着工程中源码的级数递增和以类型.功能.模块组织源码的子目录的增多,都不愿意重复机械地手工编写这个工程管理 ...
- C# 创建XML文档
有些时候我们需要生成一个xml文档作为数据交换的容器.当然我们用拼接字符串的方法来进行构建xml,但是这种方法虽然简单有效,但是如果xml文档结构过于复杂,拼接字符串会让人眼花缭乱.这时候就需要C#给 ...
- 使用vagrant作为开发环境后,js报错
当你尝试修改一个js,并且用同样的方法更新之后,会遇到类似的问题,是的,就算重启VM上任何服务,甚至重启VM,依旧没有用,当然,比起其他资源文件,浏览器的反应会强烈一些,因为浏览器会提示未知错误,而你 ...