蛇皮 @ 2020-01-21 11:35:34
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct pingguo
{
int x;
int y;
};
pingguo k[5001];
int cmp(const void* p,const void* q)
{
return (*(pingguo *)p).y > (*(pingguo *)q).y ? 1 : -1;
}
int main()
{
int num=0;
int n,s,a,b;
scanf("%d%d",&n,&s);
scanf("%d%d",&a,&b);
int h=a+b;
for(int i=0;i<n;i++)
{
scanf("%d%d",&k[i].x,&k[i].y);
}
qsort(k,n,sizeof(pingguo),cmp);
for(int i=0;i<n;i++)
{
if(k[i].x<=h&&k[i].y<=s)
{
num++;s-=k[i].y;
}
}
printf("%d",num);
}
by zhy137036 @ 2020-01-21 11:37:56
C里结构体好像不能这么用
by zhy137036 @ 2020-01-21 11:42:56
在所有pingguo
前加上struct
并且推荐使用C++,
by zhy137036 @ 2020-01-21 11:43:32
by 蛇皮 @ 2020-01-21 11:53:27
@zhy123456 竞赛不能用万能头吧
by zhy137036 @ 2020-01-21 11:55:16
@蛇皮 当个笑话看吧,不过好像可以用万能头
by Mkarry @ 2020-01-21 12:54:10
可以用的,而且STL随便用(只要你会)
by zibiking @ 2020-09-12 20:52:06
@zhy137036 npnpnpn-p
by zhy137036 @ 2020-09-12 21:33:01
@钟安泽88 ?
by zhy137036 @ 2020-09-12 21:33:36
顺便确实能用万能头(今年 NOI 还能用 -O2 和 C++11
by zibiking @ 2020-10-03 20:18:32
@zhy137036 mousher