AtCoder Contest 228 C - Final Day

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300300 points

Problem Statement

NN students are taking a 44-day exam.

There is a 300300-point test on each day, for a total of 12001200 points.

The first three days of the exam are already over, and the fourth day is now about to begin. The ii-th student (1 \leq i \leq N)(1≤i≤N) got P_{i, j}Pi,j​ points on the jj-th day (1 \leq j \leq 3)(1≤j≤3).

For each student, determine whether it is possible that he/she is ranked in the top KK after the fourth day.
Here, the rank of a student after the fourth day is defined as the number of students whose total scores over the four days are higher than that of the student, plus 11.

Constraints

  • 1 \leq K \leq N \leq 10^51≤K≤N≤105
  • 0 \leq P_{i, j} \leq 300 \, (1 \leq i \leq N, 1 \leq j \leq 3)0≤Pi,j​≤300(1≤i≤N,1≤j≤3)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK
P_{1,1}P1,1​ P_{1,2}P1,2​ P_{1,3}P1,3​
\vdots⋮
P_{N,1}PN,1​ P_{N,2}PN,2​ P_{N,3}PN,3​

Output

Print NN lines. The ii-th line (1 \leq i \leq N)(1≤i≤N) should contain Yes if it is possible that the ii-th student is ranked in the top KK after the fourth day, and No otherwise.


Sample Input 1 Copy

Copy

3 1
178 205 132
112 220 96
36 64 20

Sample Output 1 Copy

Copy

Yes
Yes
No

If every student scores 100100 on the fourth day, the 11-st student will rank 11-st.
If the 22-nd student scores 100100 and the other students score 00 on the fourth day, the 22-nd student will rank 11-st.
The 33-rd student will never rank 11-st.


Sample Input 2 Copy

Copy

2 1
300 300 300
200 200 200

Sample Output 2 Copy

Copy

Yes
Yes

Sample Input 3 Copy

Copy

4 2
127 235 78
192 134 298
28 56 42
96 120 250

Sample Output 3 Copy

Copy

Yes
Yes
No
Yes

题目类型:没看出啥类型:)

解题目标:判断每个人在四天结束后,是否属于前K名;

注意点:1)第四天满分是300;

                2)求是否最后排名大于等于K

                3)可能存在同分情况, 且给出学生分数是无序的;

                4)某个学生的排名判断标准是大于该学生分数的人数+1(十分重要)

解题思路:1)开个两个vector<int> a, b, 两个都存当前该学生前三天的总分;

                  2)a 用sort降序排序(就有了前三天所有学生的排名了!)

                  3)遍历b, 并判断b[i]+300 是否大于a[k-1], 若是,则该同学也有可能 在前K名,输出Yes;

                       

#include <bits/stdc++.h>
#define rep(x ,a, b) for(int x =a; x<=b; x++)
#define inf 0x3f3f3f3f
using namespace std;
const int N= 1e5+10;
vector<int> a, b;
bool comp(const int &a,const int &b)
{
    return a>b;
}
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    rep(i, 0, n-1)
    {
        int s1, s2, s3;
        scanf("%d%d%d", &s1, &s2, &s3);
        s1  = s1+s2+s3;
        b.push_back(s1);
        a.push_back(s1);
    }
    sort(a.begin(), a.end(), comp);
    rep(i, 0, (int)(b.size()-1))
    {
        if(b[i]+300 >= a[k-1])
            printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值