Cod sursa(job #3326235)

Utilizator SkibidiCezarCezar Bolba SkibidiCezar Data 27 noiembrie 2025 19:45:50
Problema Statistici de ordine Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 3.2 kb
#include <bits/stdc++.h>
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/// i love alex stan so much ///
/*     /\           _____             _____ _______    /\     |\    |
      /  \    |     |       \  /     /         |      /  \    | \   |
     /----\   |     |--      \/      \_____    |     /----\   |  \  |
    /      \  |     |        /\            \   |    /      \  |   \ |
   /        \ |____ |____   /  \     ______/   |   /        \ |    \|

████████▀▀░░░░░░░░░░░░░░░░░░░▀▀███████
██████▀░░░░░░░░░░░░░░░░░░░░░░░░░▀██████
█████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████
████░░░░░▄▄▄▄▄▄▄░░░░░░░░▄▄▄▄▄▄░░░░░████
████░░▄██████████░░░░░░██▀░░░▀██▄░░████
████░░███████████░░░░░░█▄░░▀░░▄██░░████
█████░░▀▀███████░░░██░░░██▄▄▄█▀▀░░█████
██████░░░░░░▄▄▀░░░████░░░▀▄▄░░░░░██████
█████░░░░░█▄░░░░░░▀▀▀▀░░░░░░░█▄░░░█████
█████░░░▀▀█░█▀▄▄▄▄▄▄▄▄▄▄▄▄▄▀██▀▀░░█████
██████░░░░░▀█▄░░█░░█░░░█░░█▄▀░░░░██▀▀▀▀
▀░░░▀██▄░░░░░░▀▀█▄▄█▄▄▄█▄▀▀░░░░▄█▀░░░▄▄
▄▄▄░░░▀▀██▄▄▄▄░░░░░░░░░░░░▄▄▄███░░░▄██▄
██████▄▄░░▀█████▀█████▀██████▀▀░░▄█████
██████████▄░░▀▀█▄░░░░░▄██▀▀▀░▄▄▄███▀▄██*/

using namespace std;
ifstream fin ("sdo.in");
ofstream fout ("sdo.out");
int n, k, st, dr, mij, rez;
int a[3000005];
int check(int nr){
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] <= nr){
            cnt++;
        }
    }
    return cnt;
}

int main()
{
    fin >> n >> k;
    for(int i = 1; i <= n; i++){ fin >> a[i]; }
    st = 1;
    dr = INT_MAX;
    while(st <= dr){
        mij = (st + dr) / 2;
        if(check(mij) >= k){
            rez = mij;
            dr = mij - 1;
        }
        else{
            st = mij + 1;
        }
    }
    fout << rez;
    return 0;
}