Created
October 10, 2019 13:33
-
-
Save surinoel/eccbb51f0bc98014e5f35c72575ec70d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <queue> | |
#include <iostream> | |
using namespace std; | |
struct paper { | |
int idx; | |
int importance; | |
paper(int idx = 0, int importance = 0): | |
idx(idx), importance(importance) { | |
} | |
}; | |
bool operator<(const paper& u, const paper& v) { | |
if (u.importance == v.importance) { | |
return u.idx < v.idx; | |
} | |
return u.importance < v.importance; | |
} | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
int tc; | |
cin >> tc; | |
while (tc--) { | |
int n, m; | |
cin >> n >> m; | |
priority_queue<paper> pq; | |
for (int i = 0; i < n; i++) { | |
int imp; | |
cin >> imp; | |
pq.push(paper(i, imp)); | |
} | |
int ans = 1; | |
while (!pq.empty()) { | |
if (pq.top().idx == m) { | |
break; | |
} | |
pq.pop(); | |
ans += 1; | |
} | |
cout << ans << '\n'; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment