-
-
Save theortsac/0c3149c4eb5f66ccf3f1294b8db0ce28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int a[505]; | |
int main() { | |
int n, k; | |
cin >> n >> k; | |
for (int i = 0; i < n; i++) { | |
cin >> a[i]; | |
} | |
int x = 100; | |
while (true) { // loop infinito pois vamos quebrar dentro do próprio loop com break | |
int qtd = 0; | |
for (int i = 0; i < n; i++) { | |
if (a[i] >= x) qtd++; | |
} | |
if (qtd >= k) break; | |
x--; | |
} | |
cout << x << "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment