题意是:给定一组整数,通过移动使这个序列变为递增的,移动i元素的话费为i
例如 2 2 5 3 4通过移动5使得序列变为2 2 3 4 5故最小花费为5,如果移动3 4那么花费会为7
这道题可以通过求“最重上升子序列”来间接地得到结果,
dp[i]表示以weight[i]
为终点递增的最重的一系列书的重量之和。状态转移方程是
dp[i] = max(dp[i], dp[k] + ...
分类:
其他好文 时间:
2015-05-22 21:14:13
阅读次数:
107
题目大意:给定一棵树,初始每个点都有一个颜色,支持三种操作:
1.将某个点到根的路径上所有点染上一种新的颜色
2.将某个点到根的路径上所有点染上一种新的颜色,然后把根设为这个点
3.定义一个点的代价为这个点到根路径上颜色的种类数,求某个点子树中所有点代价的平均值我真是炖了狗了……
容易发现这玩应就是个LCT,操作1就是Access,操作2就是Move_To_Root,代价就是一个点到根路径上...
分类:
其他好文 时间:
2015-05-22 19:17:20
阅读次数:
168
题目:
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or...
分类:
编程语言 时间:
2015-05-22 17:12:06
阅读次数:
221
在vimrc中加入如下代码即可 inoremap <C-A> <Esc>^i
inoremap <C-E> <Esc>$i
inoremap <C-L> <Right>
inoremap <C-H> <Left>
inoremap <C-J> <Down>
inoremap <C-K> <Up>
"move to next word
inoremap <C-F> ...
分类:
移动开发 时间:
2015-05-22 13:38:35
阅读次数:
164
看了网上那么多的博客 ,对于android系统的事件处理仍然不是明白的特别透彻,或者一些博客讲解的总是有些歧义或者讲诉的不正确或者不全面。所以自己总结了一下事件的传递机制希望可以帮助到广大的朋友。
假设事件传送路径为A-B-C-D-E;
一个手势是由事件action_down开始和action_move等其它事件以及事件action_up结束的集合;
一个action_down意味着一个新的手势的开...
分类:
移动开发 时间:
2015-05-22 11:39:12
阅读次数:
165
设置窗口居中显示方法一:在窗口(QWidget类及派生类)的构造函数中添加如下代码:#include //.......QDesktopWidget* desktop = QApplication::desktop(); // =qApp->desktop();也可以move((desktop->w...
Android中的事件分为按键事件和触摸事件。
Touch事件是由一个ACTION_DOWN,n个ACTION_MOVE,一个ACTION_UP组成onClick,onLongClick,onScroll等事件,Android 中与 Touch 事件相关的方法有:
dispatchTouchEvent(MotionEvent ev) 事件分发
onInterceptTouchEvent(...
分类:
移动开发 时间:
2015-05-21 10:50:21
阅读次数:
161
1 题目Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the...
分类:
编程语言 时间:
2015-05-20 23:44:52
阅读次数:
156
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
Note: You can only move either down or right at...
分类:
其他好文 时间:
2015-05-20 18:34:22
阅读次数:
138
这篇文章用来讲解,如何跟踪touch event的轨迹。onTouchEvent()方法 由 ACTION_MOVE 事件触发(只要当前的接触的 position, pressure,size发生了变化)。 就像上一篇文章 Detecting Common Gestures讲到的一样,这些event会被记录在MotionEvent中,而这个MotionEvent将作为onTouchEvent()的参...
分类:
其他好文 时间:
2015-05-20 13:16:00
阅读次数:
154