Problem Description
As everyone knows, the garbage collecting station is very important to our daily life. With the growing of the city, more and more garbage need to be collected timely. First, let us see what will the garbage collecting station do everyday.
The station divide the city into N*M blocks, each block contains some buindings, as the picture below shows. And the garbage collecting station lies at the suburban district, but not inside any one of these blocks.

The station will sort the blocks (b1, b2, … bK, K = N*M )by their priority in a line. For instance, after the sort process, the blocks will be arranged as a sequence b1. b2. b3….bK, then the garbage collecting lorry will begin to collect garbage at b1, loading the garbage at b1, then go to b2, loading garbage then go to b3, and so on. After loaded the garbage at bK, the lorry will go to the station and upload all the garbage.

Now the station want to build another two stations, and these two stations will build inside two different blocks bi and bj (i<j). And the garbage of blocks b1 to bi will be carried to bi, the garbage of blocks bi+1 to bj will be carried to bj, the garbage of blocks bj+1 to bK will be carried to the station at the suburban district.

Now the problem is: we assume that carrying one unit of garbage in one meter will cost \$1. Given the weight of the garbage of each block and the distance between bi and bi+1(1<=i<k), bk and the station, you should find out where to build the two new stations(i.e, choose two blocks bi and bj and make them as new stations) to make the cost as low as possible.

Input
Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.
The first line of each test case contains an integer N(1<=N<=10000), the number of blocks. N lines follow. The i-th line containing two integers, wi (the weight of garbage of block i, 1<=wi<=10000) and di(the distance between di and di+1, 1<=di<=10000), the last one dk means the distance between dk and the station.

Output
Results should be directed to standard output. For each case, output an integers S, the least \$ we have to spend to carry the garbage to the collecting station.

Sample Input
1
4
1 2
2 1
3 3
1 1

Sample Output
3

Problem Description As everyone knows, the garbage collecting station is very important to our daily life. With the growing of the city, more and more garbage need to be collected timely. First, let us see what will the garbage collecting station do everyday. The station divide the city into N*M blocks, each block contains some buindings, as the picture below shows. And the garbage collecting station lies at the suburban district, but not inside any one of these blocks. The station will sort the blocks (b1, b2, … bK, K = N*M )by their priority in a line. For instance, after the sort process, the blocks will be arranged as a sequence b1. b2. b3….bK, then the garbage collecting lorry will begin to collect garbage at b1, loading the garbage at b1, then go to b2, loading garbage then go to b3, and so on. After loaded the garbage at bK, the lorry will go to the station and upload all the garbage. Now the station want to build another two stations, and these two stations will build inside two different blocks bi and bj (i<j). And the garbage of blocks b1 to bi will be carried to bi, the garbage of blocks bi+1 to bj will be carried to bj, the garbage of blocks bj+1 to bK will be carried to the station at the suburban district. Now the problem is: we assume that carrying one unit of garbage in one meter will cost \$1. Given the weight of the garbage of each block and the distance between bi and bi+1(1<=i<k), bk and the station, you should find out where to build the two new stations(i.e, choose two blocks bi and bj and make them as new stations) to make the cost as low as possible. Input Standard input will contain multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. The first line of each test case contains an integer N(1<=N<=10000), the number of blocks. N lines follow. The i-th line containing two integers, wi (the weight of garbage of block i, 1<=wi<=10000) and di(the distance between di and di+1, 1<=di<=10000), the last one dk means the distance between dk and the station. Output Results should be directed to standard output. For each case, output an integers S, the least \$ we have to spend to carry the garbage to the collecting station. Sample Input 1 4 1 2 2 1 3 3 1 1 Sample Output 3
java的垃圾回收机制采用roottrance判断对象是否是垃圾，这个对象的多层引用怎么判断？
java的垃圾回收机制，采用的是roottrance来判断对象是否是垃圾的，这个对象的多层引用是怎么判断的呢？ 感觉[内行问答Java开发中如何巧妙提高性能](http://www.neitui.me/index.php?name=mail&handle=record&spid=119&f= java26&jumpurl=http://www.neitui.me/event/dk/26.html "")的大神回答的有点简单了，哪位了解的可以给讲一下？

java垃圾回收的疑问
:D java垃圾回收算法中的“引用计数”法，为什么不能解决垃圾回收的问题呢？
JVM年轻代垃圾回收问题

Java的垃圾回收机制管理的区域

1.java在内存紧缺时候会回收掉不用的静态变量的内存吗？ 2.一个类中含有对静态变量的引用，当这个类不使用的时候会被垃圾回收吗？

``` var i; for(i=0;i<length;i++){ } for(var i=0;i<length;i++){ } ``` 两个基础问题，我从外定义和在for循环定义i的区别在哪里 众所周知js没有块级作用域，那么我定义的i 在垃圾回收机制中算不算进入环境和离开环境呢？
HotSpot虚拟机关于垃圾回收的几个问题
HotSpot虚拟机关于垃圾回收的几个问题 假如from-survivor space有些对象达到晋升到老年代的条件，而且老年代有足够的空间。 那么当Minor GC发生时： 1、from-survivor space那些达到晋升条件的对象什么时候会进入老年代； 2、Eden space和from-survivor space的对象何时进入to-survivor space，进入时是否有优先级； 3、如果to-survivor space空间不足时剩余的对象如何处理； 4、整个过程的执行顺序是什么。 HotSpot virtual machine on garbage collection of several issues If from-survivor space some objects to reach the conditions of the old generation, and the old generation has enough space. Then when the Minor GC occurs: 1) from-survivor space Those who reach the conditions of promotion when the object will into the old age; 2) Eden space and from-survivor space when the object into the to-survivor space, whether there is priority to enter; 3) If the to-survivor space fills up, remaining objects will be how to deal with; 4) what is the order of the whole process.
java垃圾回收机制GC判断可回收对象算法
java垃圾回收机制中，讲到GC判断可回收对象算法时，有一种可达性算法，不明白它如何解决对象循环引用问题的？

android内存自动清理机制和android垃圾回收器的触发条件

java垃圾回收机制怎么回收变量

centos回收站的垃圾无法清楚，打开回收站都无法显示垃圾文件了，点清空回收站也没反应啊
centos回收站的垃圾无法清楚，打开回收站都无法显示垃圾文件了，点清空回收站也没反应啊，该怎么做？
CMS垃圾回收中的 sweep阶段感觉不能称为真正的并发?
cms中的sweep阶段写的是" After the remark pause, a concurrent sweeping phase collects the objects identified as unreachable. "但我看代码中sweep阶段需要三把锁“CMS token（禁止stw回收）；freelistLock（禁止在本堆分配）；bitMapLock（禁止访问修改bitmap）”如下图。如果sweep时持有这三把锁，那这与stw有什么区别吗？那还不如用lazy-sweep？ ![图片说明](https://img-ask.csdn.net/upload/201910/28/1572228780_454109.jpg)
JVM垃圾回收关于New Generation为什么分为三个区域的疑问

Java学习的正确打开方式

Python——画一棵漂亮的樱花树（不同种樱花+玫瑰+圣诞树喔）

HashMap 相关概念 HashTab、HashMap、TreeMap 均以键值对像是存储或操作数据元素。HashTab继承自Dictionary，HashMap、TreeMap继承自AbstractMap，三者均实现Map接口 **HashTab：**同步哈希表，不支持null键或值，因为同步导致性能影响，很少被使用 **HashMap：**应用较多的非同步哈希表，支持null键或值，是键值对...

linux系列之常用运维命令整理笔录

Python 基础（一）：入门必备知识

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。 1. for - else 什么？不是 if 和 else 才

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7

JDK12 Collectors.teeing 你真的需要了解一下

“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...