- 浏览: 36882 次
- 性别:
- 来自: 杭州
最新评论
PAT1029 Median
- 博客分类:
- PAT
用标准库的排序全部超时,需要自己实现,另外还不能用cin cout
Sample Input
4 11 12 13 14 5 9 10 15 16 17Sample Output
13
#include <stdio.h> int N1[1000000]; int N2[1000000]; int M[2000000]; int main() { int lenN1; scanf("%d",&lenN1); for (int i = 0; i < lenN1; i++) { scanf("%d",&N1[i]); } int lenN2; scanf("%d",&lenN2); for (int i = 0; i < lenN2; i++) { scanf("%d",&N2[i]); } int i = 0, j = 0, k = 0; while(i < lenN1 && j < lenN2) { if (N1[i] < N2[j]) { M[k++] = N1[i++]; } else if (N1[i] > N2[j]) { M[k++] = N2[j++]; } else { M[k++] = N1[i++]; M[k++] = N2[j++]; } } if (i < lenN1 && j >= lenN2) { while(i < lenN1) { M[k++] = N1[i++]; } } else { while(j < lenN2) { M[k++] = N2[j++]; } } if ((lenN1 + lenN2)%2) { printf("%d",M[(lenN1+lenN2)/2]); } else { printf("%d",M[(lenN1+lenN2)/2 - 1]); } return 0; }
发表评论
-
PAT1013 Battle Over Cities
2012-11-29 23:59 787Sample Input 3 2 3 1 2 1 3 ... -
PAT1003 Emergency
2012-11-29 23:46 670Sample Input 5 6 0 2 1 2 1 ... -
PAT1041 Be Unique
2012-11-23 23:43 770找出只出现过一次的数,用各种排序必然超时,需要用数组做hash ... -
PAT1042 Shuffling Machine
2012-11-23 23:42 740扑克洗牌 #include < ... -
PAT1040 Longest Symmetric String
2012-11-23 23:41 966求最长回文子串 #include < ... -
PAT1036 Boys vs Girls
2012-11-23 23:41 721Sample Input 1: 3 Joe M Mat ... -
PAT1035 Password
2012-11-23 23:40 624Sample Input 1: 3 Team0000 ... -
PAT1031 Hello World for U
2012-11-22 23:54 660Sample Input: helloworld! S ... -
PAT1028 List Sorting
2012-11-22 23:53 816用vector最后一个用例超时了。。。 Sample ... -
PAT1027 Colors in Mars
2012-11-22 23:52 633Sample Input 15 43 71 Samp ... -
PAT1025 PAT Ranking
2012-11-22 23:51 778Sample Input: 2 5 123456789 ... -
PAT1023 Have Fun with Numbers
2012-11-21 23:55 693大数的相加 比较两个字符串中字符完全相同 Sa ... -
PAT1020 Tree Traversals
2012-11-21 23:54 660已知中序遍历 后序遍历,求层次遍历 Sample In ... -
PAT1019 General Palindromic Number
2012-11-21 23:53 542十进制转任意进制,并比较是否是回文数 Sample I ... -
PAT1037 Magic Coupon
2012-11-21 15:46 668Sample Input: 4 1 2 4 -1 ... -
PAT1038 Recover the Smallest Number
2012-11-20 23:52 1675由一道面试题改的 把数组排成最小的数 不同之处是这 ... -
PAT1024 Palindromic Number
2012-11-20 23:51 654Sample Input 1: 67 3 Sampl ... -
PAT1015 Reversible Primes
2012-11-19 23:51 776十进制转任意进制 假设十进制数为number,转 ... -
PAT1012 The Best Rank
2012-11-19 23:50 935四门功课,输出排名最高的是哪个 Sample Inpu ... -
PAT1011 World Cup Betting
2012-11-19 23:50 538Sample Input 1.1 2.5 1.7 1.2 ...
相关推荐
sci文章 The gravity p-median model
adaptive median algorithm
TLD开源代码MedianFlow部分,改造成一个运行程序示例,包含测试主程序及测试视频序列。运行环境:vs2008 + opencv2.4.2
该文件是图像中值滤波和平滑滤波的MATLAB源程序。
中值滤波median_filtermedian_filtermedian_filtermedian_filtermedian_filter
MEDIAN_POLISH Fits an additive model using Tukey s median polish procedure.
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is 15. The...
This document contains a more detailed analysis of the Select or median of medians algorithm than is contained in the text.
A fast median filter using AltiVec,一种有效的中值滤波快速算法。
this is 3x3 median filter for test.
ZJU考研机试真题 九度1004Median
论文Median filtering in constant time 一文提供的源代码
017_影像平滑(medianBlur、bilateralFilter) _ 阿洲的程式教學1
自己写的matlab中值滤波程序,简单易懂。滤除噪音,图像模糊
按照多媒体课本上的步骤,严格执行中值区分算法,将24位图像转换为256色图
DBUTM Trimmed Median Filter
1.领域:matlab,directional weighted median filter(DWMF)图像的方向加权中值滤波图像去噪 2.内容:directional weighted median filter(DWMF)图像的方向加权中值滤波图像去噪matlab仿真+matlab操作视频 3.用处...
fingding the median distributively
There are two sorted arrays nums1 and nums2 of size m and n respectively. ...Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Java AC版本
a new directional weighted median filter for removal of random-valued impulse noise,附带matlab代码的