//============================================================================
// Name : 1442.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <stdio.h>
#include <queue>
#define M 3000
using namespace std;
int main() {
int m, n, v;
scanf("%d %d", &m, &n);
int data[m];
for (int i = 0; i < m; i++)
scanf("%d", &data[i]);
priority_queue<int, vector<int>, greater<int> > qbig;
priority_queue<int> qsmall;
int l = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &v);
while (l < v) {
qbig.push(data[l++]);
}
qsmall.push(qbig.top());
qbig.pop();
if (!qbig.empty() && !qsmall.empty()) {
while (qbig.top()< qsmall.top()) {
qsmall.push(qbig.top());
qbig.push(qsmall.top());
qsmall.pop();
qbig.pop();
}
}
int top = qsmall.top();
printf("%d\n",top);
}
return 0;
}
poj1442
最新推荐文章于 2020-02-12 13:15:46 发布