codeforces 967 D Resource Distribution
題目
One department of some software company has n servers of different specifications. Servers are indexed with consecutive integers from
In order for production to work, it is needed to deploy two services
The described situation happens in an advanced company, that is why each service may be deployed using not only one server, but several servers simultaneously. If service
Each server may be left unused at all, or be used for deploying exactly one of the services (but not for two of them simultaneously). The service should not use more resources than the server provides.
Determine if it is possible to deploy both services using the given servers, and if yes, determine which servers should be used for deploying each of the services.
Input
The first line contains three integers
The second line contains
Output
If it is impossible to deploy both services using the given servers, print the only word “No” (without the quotes).
Otherwise print the word “Yes” (without the quotes).
In the second line print two integers
In the third line print
In the fourth line print
No index may appear twice among the indices you print in the last two lines. If there are several possible answers, it is allowed to print any of them.
Examples
Input |
---|
6 8 16 3 5 2 9 8 7 |
Output |
Yes 3 2 1 2 6 5 4 |
Input |
---|
4 20 32 21 11 11 12 |
Output |
Yes 1 3 1 2 3 4 |
Input |
---|
4 11 32 5 5 16 16 |
Output |
No |
Input |
---|
5 12 20 7 8 4 11 9 |
Output |
No |
Note
In the first sample test each of the servers
In the second sample test the first server will provide
分析
【題意】
給出
- 選取
k1 個資源數不小於x1k1 的伺服器使資源總和不小於x1 - 選取
k2 個資源數不小於x2k2 的伺服器使資源總和不小於x2 - 兩次選取的伺服器不能有交叉
【分析】
伺服器貪心:連續選擇
⌈x1cmin⌉ 個伺服器
假設對於x1已經選擇了n個伺服器,要求每個伺服器的資源數都不小於x1n ,只要最小的資源數不小於這個值就行了,也就是cmin≥x1n⇒cmin⋅n≥x1 。可以理解為,一個伺服器的集合實際上最多提供cmin⋅n 個資源。那麼從貪心的角度