Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
超时。。的命#include<iostream> #include<string> #include<stdlib.h> using namespace std; #define MAX 100002 int cmp ( const void *a , const void *b ) { return *(int *)a - *(int *)b; } int main() { int N, m, p, q; cin >> N >> m; int x = 1, number, i; int a[MAX] = {0}; char b[MAX] = {'0'}; char cpy[MAX]; while(N --) cin >> b[x ++]; strcpy(cpy,b); while(m --) { for(i = 1; b[i] != '0'; i ++ ) a[i] = b[i] - '0'; scanf("%d%d%d", &p, &q, &number); qsort(a + p, q - p + 1, sizeof(int), cmp); printf("%d\n", a[p + number - 1]); //接下来应该返回 回到为排序时 strcpy(b,cpy); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator