NBUT 1029 金坷垃一亩一千八(字典序排序值得学习~)

题目链接:https://ac.2333.moe/Problem/view.xhtml?id=1029

#include
#include
#include
#include
using namespace std;
int n,ans;
long long k;
struct Node
{
    char name[20];
    long long want,shiji;
    int food;
} a[100000];
bool cmp(struct Node q,struct Node p)
{
    char *s1=q.name;
    char *s2=p.name;
    if(q.food==p.food)
        return strcmp(s1,s2)<0;
    return q.food>p.food;
}
bool cmp1(struct Node q,struct Node p)
{
    char *s1=q.name;
    char *s2=p.name;
    if(q.shiji==p.shiji)
        return strcmp(s1,s2)<0;
    return q.shiji>p.shiji;
}
int main()
{
    while(~scanf("%d%lld",&n,&k))
    {
        for(int i=0; i


你可能感兴趣的:(思维训练)