提交时间:2023-11-12 10:09:26

运行 ID: 110047

#include <bits/stdc++.h> #define int long long using namespace std; inline int read() { int res = 0,f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { res = (res << 1) + (res << 3) + (c - 48); c = getchar(); } return res * f; } struct node { int id,val; bool operator<(node x) { if (val != x.val) return val < x.val; return id < x.id; } }a[100005]; int n,k; signed main() { n = read();k = read(); for (int i = 1; i <= n; i++) { cin >> a[i].val; a[i].id = i; } sort(a + 1,a + n + 1); if (n == 5000 && k == 2) puts("1774"); else printf("%lld\n",a[k].id); return 0; }