Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位大牛帮我看一下代码?

Posted by 1016120600 at 2011-06-26 16:20:50 on Problem 2104
#include <algorithm>
#include <functional>
#include<cstdio>
#include<vector>
using namespace std;
int main()
{
    vector<int>a,b;
    int i,m,n,s;
    scanf("%d%d",&m,&n);
    for(i=0; i<m; i++)
    {
        scanf("%d",&s);
        a.push_back(s);
    }
    int j,begin,end,nth;
    for(j=0; j<n; j++)
    {
        scanf("%d%d%d",&begin,&end,&nth);
        vector<int> ::iterator p1,p2;
        s=end-begin;
        for(i=0; i<=s; i++)
            b.push_back(a[i+begin-1]);
        p1=b.begin();
        p2=b.end();
        make_heap(p1,p2,greater<int>());
        for(i=1; i<nth; i++)
            pop_heap(p1,p2--,greater<int>());
        printf("%d\n",b.front());
        b.clear();
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator