#include <iostream> #include <math.h> #include <vector> #include <algorithm> #include <queue> #include <typeinfo> #define c_plus_plus std #define QED return 0 #define NOT_QED return -1 #define CNU return #define kiedy_kliknieto_zielona_flage int main() #define ll long long #define mp make_pair #define str string #define vec vector #define pb push_back #define foru(u, n) for(int u=0;u<n;u++) #define INT_MAX 2147483647 #define LL_MAX 9223372036854775807LL #define ir(a, b, x) ((a<=x)&&(x<=b)) #define f first #define s second #define ll long long #define vll vec<ll> using namespace c_plus_plus; kiedy_kliknieto_zielona_flage{ int n; int k; cin >> n; cin >> k; vll tbl; foru(i, n) {int x; cin >> x; tbl.pb(x);} sort(tbl.begin(), tbl.end(), std::greater<int>()); int cutoff = tbl[k-1]; int pnt = 0; for(pnt=0;pnt<n;pnt++){ if(tbl[pnt]<cutoff) break; } cout << pnt; QED; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <iostream> #include <math.h> #include <vector> #include <algorithm> #include <queue> #include <typeinfo> #define c_plus_plus std #define QED return 0 #define NOT_QED return -1 #define CNU return #define kiedy_kliknieto_zielona_flage int main() #define ll long long #define mp make_pair #define str string #define vec vector #define pb push_back #define foru(u, n) for(int u=0;u<n;u++) #define INT_MAX 2147483647 #define LL_MAX 9223372036854775807LL #define ir(a, b, x) ((a<=x)&&(x<=b)) #define f first #define s second #define ll long long #define vll vec<ll> using namespace c_plus_plus; kiedy_kliknieto_zielona_flage{ int n; int k; cin >> n; cin >> k; vll tbl; foru(i, n) {int x; cin >> x; tbl.pb(x);} sort(tbl.begin(), tbl.end(), std::greater<int>()); int cutoff = tbl[k-1]; int pnt = 0; for(pnt=0;pnt<n;pnt++){ if(tbl[pnt]<cutoff) break; } cout << pnt; QED; } |