优先队列做,然后遍历人数。
#include#include #include #define maxn 150010using namespace std;struct node{ int id; int val; friend bool operator < (node a ,node b){ if(a.val==b.val) return a.id > b.id; return a.val < b.val; }}a[maxn];priority_queue q;int n,x[maxn],ans[maxn];char name[maxn][210];int main(){ int i,j,t,m,p; scanf("%d", &t); while(t--) { scanf("%d %d %d", &n, &m, &p); memset(x,0,sizeof(x)); for(i=1; i<=n; i++) { scanf("%s %d", name[i], &a[i].val); a[i].id=i; ans[i]=0; } for(i=0; i