提交时间:2023-11-08 13:24:15
运行 ID: 109297
#include<bits/stdc++.h> #define int long long using namespace std; int n,m; struct P{ int sum,id; }a[114514]; bool cmp(P a,P b){ if (a.sum == b.sum){ return a.id < b.id; } return a.sum < b.sum; } signed main(){ cin>>n>>m; for (int i = 1;i <= n;i++){ cin>>a[i].sum; a[i].id = i; } sort(a + 1,a + n + 1,cmp); cout<<a[m].id; return 0; }