首页 > 其他 > 详细

洛谷 P1801 黑匣子_NOI导刊2010提高(06)

时间:2019-08-02 01:55:36      阅读:84      评论:0      收藏:0      [点我收藏+]

题目传送门

解题思路:

懒得写,看大佬的题解,题解传送门

AC代码:

 1 #include<cstdio>
 2 #include<iostream>
 3 #include<queue>
 4 
 5 using namespace std;
 6 
 7 int m,n,a[200001],b,tot = 1,j;
 8 priority_queue<int> big;
 9 priority_queue<int,vector<int>,greater<int> > small;
10 
11 int main()
12 {
13     scanf("%d%d",&n,&m);
14     for(int i = 1;i <= n; i++)
15         scanf("%d",&a[i]);
16     for(int i = 1;i <= m; i++) {
17         scanf("%d",&b);
18         for(j = tot;j <= b; j++){
19             big.push(a[j]);
20             if(big.size() == i) {
21                 small.push(big.top());
22                 big.pop();
23             }
24         }
25         tot = b + 1;
26         printf("%d\n",small.top());
27         big.push(small.top());
28         small.pop();    
29     }
30     return 0;
31 }

 

洛谷 P1801 黑匣子_NOI导刊2010提高(06)

原文:https://www.cnblogs.com/lipeiyi520/p/11286152.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!