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 <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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator