158A - Next Round
作者:
社交帐号直接注册 | 来源:发表于
2018-01-11 20:54 被阅读0次#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
int m[101];
int i;
cout << endl;
for (i = 0; i < n; i++)
{
cin >> m[i];
}
sort(m, m + n);
cout << endl;
for (i = n - 1; i >= 0; i--)
{
cout << m[i] << endl;
}
cout << endl;
int a=0, b=0;
for (i = n - 1; i >= 0; i--)
{
if (m[i] > 0&&b<=k)
{
if (m[i] > m[i - 1])
{
a++;
b++;
}
else if(m[i]==m[i-1])
{
a++;
}
else
{
break;
}
}
else
{
break;
}
}
cout << a << endl;
system("pause");
}
本文标题:158A - Next Round
本文链接:https://www.haomeiwen.com/subject/mblanxtx.html
网友评论