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 & ...
随机推荐
- xilinx 网站资源导读
[经验整理.01]Xilinx网站资源导读 ISE11版 标签: ISE Xilinx 入门 资源 2009-09-01 20:41 序 虽然自己也曾想过,但如果不是向农要求,把曾经写过的文 ...
- jquery animate() 防止多次执行
参考:关于jquery 怎样让 animate不多次执行呢 当click方法里面,执行animate时,然后点击的比较频繁,那么animate()的动画也会比较多次滚动. 如: function sc ...
- 1.1、Mybatis一级缓存测试
package me.gacl.test; import me.gacl.domain.User; import me.gacl.util.MyBatisUtil; import org.apache ...
- ACM——Quicksum
Quicksum 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:615 测试通过:256 描述 A chec ...
- Cordova+angularjs+ionic+vs2015开发(四)
欢迎加群学习:457351423 这里有4000多部学习视频,涵盖各种技术,有需要的欢迎进群学习! 一.布局 Ionic模板提供了一个侧边栏菜单示例项目和标签选项卡示例项目.本案例将两个布局进行结合, ...
- 如何防止SWF文件被反编译
这篇文章的标题所提出的问题的答案是“不可能”.至少对我来说是不可能的.借助适当的工具,我们可以反编译任何SWF文件.所以,不要将重要的信息置于SWF文件中.SWF文件中不要包含个人的帐号或者密码. 我 ...
- ###学习《C++ Primer》- 3
点击查看Evernote原文. #@author: gr #@date: 2014-10-04 #@email: forgerui@gmail.com Part 3: STL泛型算法(第10章) 一. ...
- springmvc学习(四)
1.使用 @CookieValue 绑定请求中的 Cookie 值 例子: java @RequestMapping(value="/testCookieValue") publi ...
- Executors 构建线程池
Executors包含一系列静态方法,可以用于构建线程池. 返回实现了 ExecutorService 接口的对象: newCachedThreadPool newFixedThreadPool(in ...
- iOS中XML的相关知识
1.什么是XML “当 XML(扩展标记语言)于 1998 年 2 月被引入软件工业界时,它给整个行业带来了一场风暴.有史以来第一次,这个世界拥有了一种用来结构化文档和数据的通用且适应性强的格式,它不 ...