<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Codeforces Round #689 (Div. 2, based on Zed Code Competition) E. Water Level 貪心

      E. Water Level

      In recent years John has very successfully settled at his new job at the office. But John doesn't like to idly sit around while his code is compiling, so he immediately found himself an interesting distraction. The point of his distraction was to maintain a water level in the water cooler used by other zebras.

      Originally the cooler contained exactly ?? liters of water. John decided that the amount of water must always be at least ?? liters of water but no more than ?? liters. John will stay at the office for exactly ?? days. He knows that each day exactly ?? liters of water will be used by his colleagues. At the beginning of each day he can add exactly ?? liters of water to the cooler, but at any point in time the amount of water in the cooler must be in the range [??,??].

      Now John wants to find out whether he will be able to maintain the water level at the necessary level for ?? days. Help him answer this question!

      Input

      The first line of the input contains six integers ??, ??, ??, ??, ?? and ?? (1≤??≤??≤??≤1018;1≤??≤1018;1≤??≤106;1≤??≤1018) — initial water level, the required range, the number of days, daily water usage and the exact amount of water that can be added, respectively.

      Output

      Print "Yes" if John can maintain the water level for ?? days and "No" otherwise.

      Examples

      inputCopy

      8 1 10 2 6 4

      outputCopy

      No

      inputCopy

      8 1 10 2 6 5

      outputCopy

      Yes

      inputCopy

      9 1 10 9 2 9

      outputCopy

      No

      inputCopy

      20 15 25 3 5 7

      outputCopy

      Yes

      Note

      In the first example, John can't increase the amount of water at the beginning of the first day, since it would exceed the limit ??. That is why after the first day the cooler will contain 2 liters of water. The next day John adds 4 liters to the cooler but loses 6 liters, leaving John with 0 liters, which is outside the range [1,10].

      In the second example, after the first day John is left with 2 liters of water. At the beginning of the next day he adds 5 liters, then 6 liters get used, leaving John with 1 liter of water which is in range [1,10].

      In the third example, after the first day John is left with 7 liters, after the second day — 5 liters, after the fourth — 1 liter. At the beginning of the fifth day John will add 9 liters and lose 2 liters. Meaning, after the fifth day he will have 8 liters left. Then each day the water level will decrease by 2 liters and after the eighth day John will have 2 liters and after the ninth day — 0 liters. 0 is outside range [1,10], so the answer is "No".

      In the fourth example, after the first day John is left with 15 liters of water. At the beginning of the second day he adds 7 liters and loses 5, so after the second day he is left with 17 liters. At the beginning of the third day he adds 7 more liters of water and loses 5, so after the third day he is left with 19 liters. 19 is in range [15,25] so the answer is "Yes".

      題意

      有個飲水機,一開始有k升水。

      每天早上你可以往里面加y升水,每天晚上你的同事一定會喝掉x升水

      問你能否有一種方案使得t天內(nèi),水都在[l,r]這個范圍。

      題解

      分成兩種情況討論:

      第一種情況 x>=y的時候,當y>=x 即 我每天加的水小于同事喝的水的時候,我貪心使得每天降的盡量少就行。第一天如果k+y<=r,我就加水,否則不加。剩下的每一天都加水。判斷一下天數(shù)是否大于等于t即可。

      第二種情況y>x的時候,當x>y的情況,即每天我加的水比喝的水多。那么先讓同事隨便喝,直到不能喝位置,然后我再加一次水。然后再讓同事喝水,我再加一次水,這樣一直循環(huán)即可。如果當前水量曾經(jīng)遇到過,那么就說明可以無限循環(huán)了。因為每天剩下的水量等于 k mod x,所以最多遇到x次,復(fù)雜度O(x)

      代碼

      #include<bits/stdc++.h>
      using namespace std;
      long long k,l,r,t,x,y;
      const int maxn = 1e6+5;
      int vis[maxn];
      bool check(long long now) {
      	if (now > r || now < l) {
      		return false;
      	}
      	return true;
      }
      void solve1() {
      	if (k+y>r) {
      		t--;
      		k-=x;
      	}
      	if (!check(k)) {
      		cout<<"NO"<<endl;
      		return;
      	}
      	int gap=x-y;
      	if (gap == 0) {
      		cout<<"YES"<<endl;
      		return;
      	}
      	// cout<<k<<" "<<l<<" "<<gap<<" "<<t<<endl;
      	if((k-l)/gap>=t) {
      		cout<<"YES"<<endl;
      	} else {
      		cout<<"NO"<<endl;
      	}
      }
      void solve2() {
      	// step 0 k->l
      	long long num1 = (k-l)/x;
      	if (num1 >= t) {
      		cout<<"YES"<<endl;
      		return;
      	}
      	k = k-num1*x;
      	t-= num1;
      	// step 1 無限循環(huán)的增加一次,減少無數(shù)次
      	while((!vis[k])&&t>0) {
      		// cout<<k<<" "<<t<<endl;
      		vis[k]=1;
      		k=k+y;
      		if(!check(k)) {
      			cout<<"NO"<<endl;
      			return;
      		}    
      		long long num2 = (k-l)/x;
      		t-=min(num2,t);
      		k=k-num2*x;
      		// cout<<"2:" << k<<" "<<t<<endl;
      	}
      	cout<<"YES"<<endl;
      }
      int main() {
      	cin>>k>>l>>r>>t>>x>>y;
      	k-=l;
      	r-=l;
      	l=0;
      	if (x>=y) {
      		solve1();
      	} else {
      		solve2();
      	}
      }
      
      posted @ 2020-12-16 01:08  qscqesze  閱讀(224)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 成人爽a毛片免费| 少妇办公室好紧好爽再浪一点| 欧美亚洲综合成人a∨在线| 国产av中文字幕精品| 亚洲成a人片在线观看中| 伊人蕉久影院| 无码AV无码免费一区二区| 国产熟女激情一区二区三区| 精品国产粉嫩内射白浆内射双马尾| 精品国产不卡在线观看免费| 精品国产亚洲午夜精品a| 两性午夜刺激性视频| 国内精品久久毛片一区二区| 亚洲尤码不卡av麻豆| 男女啪啪免费观看网站| 女人香蕉久久毛毛片精品| 华人在线亚洲欧美精品| 国产乱国产乱老熟300部视频| 亚洲第一狼人天堂网伊人| 婷婷久久香蕉五月综合加勒比 | 亚洲成av人片乱码色午夜| 国产精品久久久久久久久软件| 94人妻少妇偷人精品| 国产精品亚洲五月天高清| 国产成人精品久久综合| 精品一区二区三区在线观看l| 久久精品一区二区东京热| 无码va在线观看| 免费国产精品视频在线| 永久免费无码国产| 精品久久精品午夜精品久久 | 久久av色欲av久久蜜桃网| 亚洲日韩中文字幕在线播放| 亚洲中文字幕精品第一页| 亚洲无线观看国产精品| 亚洲乱码一二三四区国产| 国产精品国产三级国快看| 人妻体内射精一区二区三区| 尤物蜜芽国产成人精品区| 亚洲中文字幕国产精品| 久久国产精品免费一区|