毕竟是HDU收录的题,,我怀疑它要变土。。
题意:
有n个项目,然后第一行输入损失度,第二行输入耗时
然后安排一下顺序,
每一项的消耗为当前已经做了的(包括此项)总时间*损失度。
求最小总消耗。
首先这道题是贪心,我们可以贪心排序项目。
策略: bool operator < (const YYC &a)const
{return x*a.y
证明:
首先我们考...
分类:
其他好文 时间:
2015-01-19 09:17:28
阅读次数:
159
条款11:在operator=中处理“自我赋值”
自我赋值有时候不是那么明显,在处理循环(a[i] = a[j])、指针(*px
= *py)和参数传递(func(const Base &rb, const Derived *pd))的时候可能会发生。
Widget::operator=(const Widget& rhs){ delete pb; pb = new...
分类:
编程语言 时间:
2015-01-17 12:44:54
阅读次数:
258
调用对象call object;声明上下文对象declarative environment record;作用域链scopechain;变量解析:variable resolution;引用错误referenceError表达式expression计算evaluate运算符operator原始表达...
分类:
编程语言 时间:
2015-01-16 19:03:35
阅读次数:
210
在前一篇文章中,介绍到了Galaxy的增量计算性质,其state是框架内部管理的,以及与Storm的简单对比。这篇文章将讲述更多Galaxy增量模型的事情,并介绍这套增量模型之上实现的Galaxy SQL和Galaxy Operator,同时会从增量角度对比Spark Streaming。...
分类:
其他好文 时间:
2015-01-16 16:42:07
阅读次数:
652
参考:http://www.cnblogs.com/springfor/p/3871008.htmlDivide two integers without using multiplication, division and mod operator.If it is overflow, retur...
分类:
其他好文 时间:
2015-01-16 16:26:25
阅读次数:
152
//SGI STL以deque作为缺省情况下的stack底部结构,stack没有迭代器,不提供遍历功能//queue的实现类似stack,也是以deque作为缺省底层结构template >class stack{ friend bool operator==__STL_NULL_TMPL_A...
分类:
其他好文 时间:
2015-01-16 14:37:03
阅读次数:
310
一、C++默默编写并调用了哪些函数 当你写下: class CEmpty { } 这就好像你写下 class CEmpty { public: CEmpty(){…} CEmpty(const CEmpty &rhs){…} ~CEmpty(){…} CEmpty& operator=(const ...
分类:
其他好文 时间:
2015-01-16 12:41:08
阅读次数:
128
转自:http://blog.sina.com.cn/s/blog_4cf015f201009o1d.html第一种情况作为Stringizing Operator(#),暂叫字符串化吧。#define stringer( x ) printf( #x "\n" ) int main() { ...
分类:
编程语言 时间:
2015-01-15 17:46:48
阅读次数:
202
简单了写了query和list的实现,特将代码放在这里,以备后续查看。
query:
QueryItem.h
#ifndef QUEUEITEM
#define QUEUEITEM
#include
using namespace std;
template class Queue;
template
ostream& operator &);
template
istream&...
分类:
其他好文 时间:
2015-01-15 14:16:38
阅读次数:
97
b = operator.itemgetter(1) 定义函数b,用于获取传入list的第1域的值
可以将b用于sort函数的key。作为排序的依据。
adn_app_data_map是个字典
for key, app_arr in adn_app_data_map.items():
app_arr.sort(key=operator.ite...
分类:
编程语言 时间:
2015-01-14 16:51:53
阅读次数:
205