BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #34075同步于 2009/12/23
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

acm那个网站上的一道题,他说output time limit exceed,请教一

cfy744674198
2009/12/23镜像同步10 回复
//#include <stdio.h> //#include <stdlib.h> #include <iostream> using namespace std; //#include <algorithm> //#include <ctime> //#include <cstdlib> //#include <iostream> //using namespace std; /* void InsertSort(int r[],int n) { int j; for (int i = 2;i <= n;i ++) { r[0] = r[i]; for (j = i-1;r[0] > r[j];j --) r[j+1]=r[j]; r[j+1]=r[0]; } }; */ void SelectSort(int r[],int n) { int index; for (int i = 1;i < n;i ++) { index = i; for (int j = i + 1;j <= n;j ++) if (r[j] > r[index]) index = j; if (index != i) swap(r[i],r[index]); } }; /* void shuffle(int* a, int size) { for (int i=0; i<size; a[i]=i, i++); for (int i=0; i<size; i++) swap(a[i], a[i+rand()%(size-i)]); } */ main() { int Max[50000]; int M,N; int i,j; int Mth; // srand(time(NULL)); // shuffle(Max, 50000); // freopen("in.txt", "w", stdout); // cout << "50000 10000" << endl; // for (int i=0;i<50000; i++) // cout << Max[i] << " "; // cout << endl; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); // clock_t start = clock(); scanf("%d %d",&N,&M); for (i = 1;i <= N;i ++) scanf("%d",&Max[i]); // InsertSort(Max,N); SelectSort(Max,N); Mth = Max[1]; for (i = 2,j = 1;i <= N,j!= M;i ++) if (Max[i] < Mth) { Mth = Max[i]; j++; } printf("%d",Mth); // clock_t end = clock(); // cout << endl << end - start << " ms" << endl; // system("pause"); // return 0; }
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
cfy744674198机器人#1 · 2009/12/23
Description Now, there are a list of N numbers. Your job is to find the Mth largest number X. (there are M-1 numbers >= X) Input There are 2 lines for the case. In the first line, there are 2 numbers N and M.( M < N ) In the second line, there are N numbers.( all numbers are intger) N <= 500000. Output you should output one number which is the Mth largest number in the list. Sample Input 5 1 2 4 0 4 4 Sample Output 4 这是那道题的题目
Raiden机器人#2 · 2009/12/23
output time limit exceed 没有这个吧…… output limit exceed的话,检查一下输出是不是符合题目的规定
cfy744674198机器人#3 · 2009/12/23
额,我的输出只有一个数,为什么他还说我output limit exceed?难道是计算时间超过了?
Raiden机器人#4 · 2009/12/23
到底是output limit exceed还是time limit exceed啊 后者的话,优化算法吧
cfy744674198机器人#5 · 2009/12/23
是output limit exceed,他没说我时间超了,我觉得可能是时间超了
wks机器人#6 · 2009/12/23
是不是死循环了?
cfy744674198机器人#7 · 2009/12/23
谢谢楼上的,是一种情况没考虑到
lichehuo机器人#8 · 2009/12/23
【 在 Raiden 的大作中提到: 】 : 到底是output limit exceed还是time limit exceed啊 : 后者的话,优化算法吧 北邮ACM的网址是什么?同学,能发给我吗?谢谢
Raiden机器人#9 · 2009/12/23
http://acm.scs.bupt.cn/ 【 在 lichehuo 的大作中提到: 】 : 北邮ACM的网址是什么?同学,能发给我吗?谢谢