Three types of answer: Map Solution, O(N) memory, O(N) init, O(1) pick. Like @dettier's Reservoir Sampling. O(1) init, O(1) memory, but O(N) to pick. ...
分类:
其他好文 时间:
2017-08-19 23:40:55
阅读次数:
239
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意: 给你N个金条和一张长度为L的桌子。每个金条长度为a[i],价值为w[i]。金条只能在桌子上横着摆一排,并且只要金条的重心(中心)在桌子上,就可以放。问你在桌子上能够摆的金条的最大总价值。 ...
分类:
其他好文 时间:
2017-08-15 10:05:40
阅读次数:
164
考察题意的理解和转化, 找到knows(候选人, i) 来传递候选人, 候选人谁也不知道. 最后确定是否是候选人, 因为前面的可能有人不知道他, 那么他就不是候选人 最佳做法:O(N)time, O(1)space The first pass is to pick out the candidat ...
分类:
其他好文 时间:
2017-08-14 14:27:00
阅读次数:
149
最近稍微有点懈怠了 刷题不勤了 勉励下自己 这道题目挺有意思的 We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I pi ...
分类:
其他好文 时间:
2017-08-14 00:34:55
阅读次数:
168
Apples and Ideas #include<bits/stdc++.h>using namespace std;#define _________ main#define ___________ while#define ____________ ' '#define ___________ ...
分类:
移动开发 时间:
2017-08-12 19:43:20
阅读次数:
240
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron... ...
分类:
其他好文 时间:
2017-08-08 20:02:14
阅读次数:
182
It is a little known fact that cows love apples. Farmer John has two apple trees (which are conveniently numbered 1 and 2) in his field, each full of ...
分类:
移动开发 时间:
2017-08-05 00:17:43
阅读次数:
178
Description Description Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan ...
分类:
其他好文 时间:
2017-08-03 11:21:16
阅读次数:
176
var santent='this is one santent. this is a santent with a list of items:'+'cherries,oranges,apples,bananas. that was the list of items.'; //创建一个字符串 v ...
分类:
编程语言 时间:
2017-08-03 11:12:11
阅读次数:
193
1、In a bar Do you come here often? I've never seen you here before. What do you think of this bar? Are you drinking___?I love that drink! Great___!(co ...
分类:
其他好文 时间:
2017-07-31 10:07:13
阅读次数:
203