Cod sursa(job #3279496)

Utilizator PitigoiOlteanEmanuelPitigoi Oltean Emanuel PitigoiOlteanEmanuel Data 23 februarie 2025 12:27:31
Problema Statistici de ordine Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <fstream>
#include <algorithm>
#include <map>
#include <vector>


using namespace std;
ifstream cin("sdo.in");
ofstream cout("sdo.out");
map <int,int,greater <int>> ma;
int n,m;


int main()
{

    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++){
        cin>>x;
        ma[x]++;
    }

    m=n-m;
    m++;
    for(auto it :ma)
    {
        m-=it.second;
        if(m<=0)
        {
            cout<<it.first;
            return 0;
        }
    }



    return 0;
}






//manuscrisul voinici