Created
February 28, 2014 07:10
-
-
Save KT-Yeh/9266675 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <set> | |
using namespace std; | |
int Case, M, N; | |
int A[30010], U[30010]; | |
int main() | |
{ | |
freopen("input.txt","rt",stdin); | |
scanf("%d", &Case); | |
while (Case--) { | |
scanf("%d %d", &M, &N); | |
for (int i = 0; i < M; ++i) | |
scanf("%d", &A[i]); | |
for (int i = 0; i < N; ++i) | |
scanf("%d", &U[i]); | |
multiset<int> Box; | |
for (int i = 0, u = 0, a = 0; u < N; ++u, ++i) | |
{ | |
while (a < U[u] && a < N) | |
Box.insert(A[a++]); | |
auto iter = Box.cbegin(); | |
for (int j = 0; j < i; ++j) | |
++iter; | |
printf("%d\n", *iter); | |
} | |
if (Case) printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment