題目大意:
要求在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
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
中國掃黃打非網
Copyright ? 2019-2025 www.alabama37th.com 版權所有
贛ICP備2023002352號-2
違法及侵權請聯系:TEL:177 7030 7066 E-MAIL:11247931@qq.com 本站由北京市萬商天勤律師事務所王興未律師提供法律服務