Problem:
Score : 200 points

Problem Statement

We have held a popularity poll for N items on sale. Item i received A_i votes.

From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.

If M popular items can be selected, print Yes; otherwise, print No.

Constraints

1 \leq M \leq N \leq 100

1 \leq A_i \leq 1000

A_i are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A_1 ... A_N

Output

If M popular items can be selected, print Yes; otherwise, print No.

Sample Input 1

4 1
5 4 2 1

Sample Output 1

Yes

There were 12 votes in total. The most popular item received 5 votes, and we can select it.

Sample Input 2

3 2
380 19 1

Sample Output 2

No

There were 400 votes in total. The second and third most popular items received less than \dfrac{1}{4\times 2} of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.

Sample Input 3

12 3
4 56 78 901 2 345 67 890 123 45 6 789

Sample Output 3

Yes

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int V = 0;
    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        V = V + A[i];
    }

    int tmp;

    for(int i=N; i>0; i--){
        for(int j=1; j<i; j++){
            if(A[j] > A[j-1]){
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
            }
        }
    }

    int tol = 0;

    double W = (V/(4*M));

    for(int i=0; i<M; i++){
        if(A[i] >= W){
            tol = tol + 0;
        }else{
            tol = tol + 1;
        }
    }

    if(tol == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}