PAT 1109 Group Photo 集体照

这题可以用双向队列,很容易就解决!

具体看代码

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 



using namespace std;



const int MAXN = 10010;


struct man{
    string name;
    int tall;
}men[MAXN];

bool cmp(man a,man b){
    if (a.tall != b.tall) {
        return a.tall > b.tall;
    }
    return a.name < b.name;
}

vector v[1010];

int main(){
    deque q;
//    printf("123\n");
    int n,k;
    scanf("%d%d",&n,&k);
    int people = n / k;
    int last = n % k + people;
    for (int i=0; i> men[i].name;
        scanf("%d",&men[i].tall);
    }
    sort(men, men+n, cmp);
    q.push_back(0);
    for (int i=1; i

 

你可能感兴趣的:(PAT)