2020 cattle off the base algorithm winter training camp 5.I - I title is a sign question sign [Title]

Topic Portal


Title Description

After 2019 a year of game, beef clan members discovered a major rule: I check in question is a question!

Check-defined question is: by number greater than or equal to 80% of the number of audience or by the number of all the problems currently more than three questions (that is, up to two questions more than it strictly by the number of people) called the attendance problem.

2020 season is coming, beef clan going to test this law, and is now known through the circumstances of each title question, I look at the title is not a sign problem.

Enter a description:

The input data of 2 rows. The first row comprises two integers n , m ( 9 n 13 , 100 m 1 000 ) n, m (9 \ leq n \ leq 13 100 \ leq m \ leq 1 \, 000) , it represents the total number of the total number of questions and the game of the match.

The second row includes a space-delimited integers n a 1 , a 2 , , a n ( a i > 0 ) a_1,a_2,\cdots,a_n(a_i > 0) , indicate the number of questions for each pass.


Output Description:

If I sign the title question is, the output Yes, otherwise the output No. (not case sensitive)


Entry

9 100
100 100 100 100 100 100 100 100 100


Export

Yes


answer

  • Row a sequence to find what you can, simple
  • May be determined directly after sorting is greater than equal to a [ 3 ] . v a l the .val [3] immediately

AC-Code

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

const int maxn = 1e5 + 7;

struct Node {
	int i;
    double val;
}a[maxn];
bool cmp(Node a, Node b) {
	return a.val > b.val;
}
int main() {
	int n, m;	while (cin >> n >> m) {
		for (int i = 0; i < n; ++i) {
			cin >> a[i].val;
			a[i].i = i + 1;
		}
        double score_9 = a[8].val;
		sort(a, a + n, cmp);
		bool flag = true;
        int cnt = 0;
		for(int i = 0; i < n && flag; ++i){
            if(a[i].i == 9){
                if(a[i].val * 100 >= m * 80 || cnt < 3)    flag = true;
                else    flag = false;
                break;
            }
            if(a[i].val != score_9)    ++cnt;
        }
		cout << (flag ? "Yes" : "No") << endl;
	}
	return 0;
}
Published 184 original articles · won praise 112 · views 10000 +

Guess you like

Origin blog.csdn.net/Q_1849805767/article/details/104305284