time limit per test: 0.25 sec. memory limit per test: 4096 KB
input: standard output: standard
It is known that to participate the All-Russian Mathematic Olympiad one should do one of other olympiads enough good. These olympiads are called "zone olympiads" and the region from which people participate the same zone olympiad is called "zone". Sarov city of Nizhny Novgorod district is situated near the boundary of zones, so every year school students of Sarov participate several zones.
This year K zones invited students from Sarov to participate their olympiads. i-th zone invited N[i] students, so N=N+N+...+N[K] totally students were invited. After the Sarov city olympiad, N students were selected, so now the olympiad authorities of Sarov have to decide, which students will participate which zone olympiad. Each student is characterized by his olympiad level and each zone is characterized by its zone level. If a student with olympiad level P participates zone with zone level Q, he will be invited to All-Russian olympiad if and only if P>Q.
Every student is also characterized by his "weight". The Sarov olympiad authorities want, that the All-Russian Olympiad will be participated by students with maximal summary weight. You are to help them. Write a program which will divide the students between zones. Keep in mind that exactly N[i] students can go to i-th zone.
On the first line of input there is an only integer K (1<=K<=100). On the second line there are K integers N, N, ... ,N[K] (0<=N[i]<=16000). On the third line there are K more integers Q, Q, ... ,Q[K] --- the zone levels of the zones. On the fourth line there are N integers P, P, ... P[N] --- olympiad levels of the students. (0<=Q[i]<=1000000, 0<=P[i]<=1000000). On the last (and fifth) line there are N integers w, w, ... w[k] --- the "weights" of students. 0<=w[i]<=100000. It is also guaranteed that 0<=N<=16000.
Output only N integers --- Z, Z, ... Z[N] --- the numbers of zones which should be participated by students 1, 2, ... N.
2 1 1 4 1 2 3 2 1
NNSU #2 team
Codeforces (c) Copyright 2010-2021 Mike Mirzayanov