https://www.acwing.com/problem/content/description/1568/
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 40010, M = 110, K = 5;
int n, m, k;
int cnt[N];
int wish[N];
vector<int> uty[M];
struct Person
{
int id, ge, gi;
int wish[K];
int total() const
{
return ge + gi;
}
bool operator< (const Person &t) const
{
if (total() != t.total()) return total() > t.total();
return ge > t.ge;
}
bool operator== (const Person &t) const
{
return ge == t.ge && gi == t.gi;
}
}p[N];
int main()
{
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < m; i ++ ) scanf("%d", &cnt[i]);
for (int i = 0; i < n; i ++ )
{
p[i].id = i;
scanf("%d%d", &p[i].ge, &p[i].gi);
for (int j = 0; j < k; j ++ )
scanf("%d", &p[i].wish[j]);
}
sort(p, p + n);
memset(wish, -1, sizeof wish);
for (int i = 0; i < n;)
{
int j = i + 1;
while (j < n && p[i] == p[j]) j ++ ;
for (int t = i; t < j; t ++ )
for (int u = 0; u < k; u ++ )
{
int w = p[t].wish[u];
if (cnt[w] > uty[w].size())
{
wish[t] = w;
break;
}
}
for (int t = i; t < j; t ++ )
if (wish[t] != -1)
uty[wish[t]].push_back(p[t].id);
i = j;
}
for (int i = 0; i < m; i ++ )
{
if (uty[i].size())
{
sort(uty[i].begin(), uty[i].end());
printf("%d", uty[i][0]);
for (int j = 1; j < uty[i].size(); j ++ )
printf(" %d", uty[i][j]);
}
puts("");
}
return 0;
}
标签:研究生,const,int,wish,入学,++,ge,uty
From: https://www.cnblogs.com/xjtfate/p/16615772.html