/*to solve the problem ,i think we can use stack to maintain the numbers,and list to keep it sorted,which is very important to find the Median number....
分类:
其他好文 时间:
2014-09-15 19:07:19
阅读次数:
181
题目: There are two sorted arrays A and B of size m and n respectively.Find the Median of two sorted arrays.The overall run time complexity should be O(...
分类:
其他好文 时间:
2014-09-15 14:19:58
阅读次数:
170
设两个数组分别为A和B,size为as和bs。原问题可以转化为两个排序数组求第k大的问题。
还是两种思路:
比较A[as/2]和B[bs/2],每次抛弃A或者B的一半
代码如下:
double findMedianSortedArrays(int A[], int m, int B[], int n) {
int total = m + n;
if (tot...
分类:
其他好文 时间:
2014-09-14 12:53:37
阅读次数:
170
MedianTime Limit:1000MSMemory Limit:65536KTotal Submissions:3866Accepted:1130DescriptionGivenNnumbers,X1,X2, ... ,XN, let us calculate the difference ...
分类:
其他好文 时间:
2014-09-13 10:34:44
阅读次数:
236
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-09-10 17:36:20
阅读次数:
172
Median of Two Sorted Arrays...
分类:
其他好文 时间:
2014-09-09 13:29:48
阅读次数:
158
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ...
分类:
其他好文 时间:
2014-09-06 17:16:13
阅读次数:
252
MedianTime Limit: 5 Seconds Memory Limit: 65536 KBThe median of m numbers is after sorting them in order, the middle one number of them if m is even o...
分类:
其他好文 时间:
2014-09-04 16:49:29
阅读次数:
190
Median-求中位数,文件中数字升序排列://Median-求中位数,文件中数字升序排列
#include<iostream>
#include<fstream>
#include<cstdlib>
intmain()
{
usingnamespacestd;
ifstreamfin;
ofstreamfout;
doublemedian,tem1,tem2;
intcount=1;
fin.op..
分类:
其他好文 时间:
2014-09-02 12:34:15
阅读次数:
196
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4736
题意:有最多10000次操作,在一个初始为空的数列中添加或移除元素并保持数列有序,每次操作后,如果数列个数为奇数就输出中间值,如果为偶数就输出中间两个值得平均值。
思路:刚开始写了一发multiset模拟,看吴琦TLE了估计他也是multiset写的,就...
分类:
其他好文 时间:
2014-09-01 17:56:43
阅读次数:
226