题解 P9044 [PA2021] Koszulki
Update:修改措辞。
分析
因为
代码
#include<bits/stdc++.h>
#define N 121
using namespace std;
inline int read() //快读
{
int x=0; bool f=1; char ch=getchar();
while(!isdigit(ch)) f=ch=='-'?0:1,ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return f?x:-x;
}
inline void write(int x) //快写
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+48);
}
int n,k,ans,t[N]; //t[N] 为桶
int main()
{
n=read(),k=read();
for(int i=1;i<=n;++i) ++t[read()]; // 用桶记录每个分数有多少人
for(int i=N-1;i>=1;--i)
if((ans+=t[i])>=k) break; //相当于 {ans+=t[i]; if(ans>=k) break;}
write(ans); //输出结果
return 0;
}