1060

作者: 峡迩 | 来源:发表于2017-09-05 10:57 被阅读0次
// PATn.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int main()
{
    unsigned n;
    cin >> n;

    vector<unsigned> data;
    for (unsigned i = 0; i < n; ++i)
    {
        unsigned tmp;
        cin >> tmp;
        data.push_back(tmp);
    }
    sort(data.begin(), data.end());

    int e_d = n;    //保证n大于0!
    int e_e = e_d;
    for (; e_d >= 0; --e_d,e_e=e_d)     //爱丁系数可以为0!0天骑车超过0英里!(怪怪的!)
    {
        int max_no_fit = n - e_d;
        int no_fit = 0;
        for (auto &r : data)
        {
            if (r <= e_e)
                no_fit += 1;

            if (no_fit > max_no_fit)
                break;
        }
        if (no_fit <= max_no_fit)
        {
            cout << e_d;
            break;
        }
    }
    
    system("pause");
    return 0;
}

相关文章

网友评论

      本文标题:1060

      本文链接:https://www.haomeiwen.com/subject/qnlujxtx.html