当前位置:Gxlcms > html代码 > CodeforcesBetaRound#4(Div.2Only)B.BeforeanExam_html/css_WEB-ITnose

CodeforcesBetaRound#4(Div.2Only)B.BeforeanExam_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:17人阅读

继续刷水题,不能再错了!!


题目大意:

要求在n天内学习t小时,给出每一天可以学习的最小时间和最大时间。问能不能实现,若可以输出时间表。



解题思路:

水题一个,保证在区间范围内的情况下直接贪心。



下面是代码:

#include #include #include #include #include #include #include #include #include #include #include #include #define eps 1e-10#define pi acos(-1.0)#define inf 107374182#define inf64 1152921504606846976#define lc l,m,tr<<1#define rc m + 1,r,tr<<1|1#define zero(a) fabs(a) 0 ? (x) : -(x))#define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))#define clearall(A, X) memset(A, X, sizeof(A))#define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))#define memcopyall(A, X) memcpy(A , X ,sizeof(X))#define max( x, y )  ( ((x) > (y)) ? (x) : (y) )#define min( x, y )  ( ((x) < (y)) ? (x) : (y) )using namespace std;struct node{    int min1,max1;}da[35];int main(){    int d,t,uplim=0,downlim=0;    scanf("%d%d",&d,&t);    for(int i=0;it)    {        puts("NO");    }    else    {        puts("YES");        t-=downlim;        for(int i=0;i=da[i].max1-da[i].min1)            {                printf("%d ",da[i].max1);                t-=da[i].max1-da[i].min1;            }            else if(t==0)            {                printf("%d ",da[i].min1);            }            else if(t

人气教程排行