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

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

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

      Codeforces Round #598 (Div. 3) C. Platforms Jumping 貪心或dp

      C. Platforms Jumping

      There is a river of width n. The left bank of the river is cell 0 and the right bank is cell n+1 (more formally, the river can be represented as a sequence of n+2 cells numbered from 0 to n+1). There are also m wooden platforms on a river, the i-th platform has length ci (so the i-th platform takes ci consecutive cells of the river). It is guaranteed that the sum of lengths of platforms does not exceed n.

      You are standing at 0 and want to reach n+1 somehow. If you are standing at the position x, you can jump to any position in the range [x+1;x+d]. However you don't really like the water so you can jump only to such cells that belong to some wooden platform. For example, if d=1, you can jump only to the next position (if it belongs to the wooden platform). You can assume that cells 0 and n+1 belong to wooden platforms.

      You want to know if it is possible to reach n+1 from 0 if you can move any platform to the left or to the right arbitrary number of times (possibly, zero) as long as they do not intersect each other (but two platforms can touch each other). It also means that you cannot change the relative order of platforms.

      Note that you should move platforms until you start jumping (in other words, you first move the platforms and then start jumping).

      For example, if n=7, m=3, d=2 and c=[1,2,1], then one of the ways to reach 8 from 0 is follow:

      The first example: n=7.

      Input

      The first line of the input contains three integers n, m and d (1≤n,m,d≤1000,m≤n) — the width of the river, the number of platforms and the maximum distance of your jump, correspondingly.

      The second line of the input contains m integers c1,c2,…,cm (1≤ci≤n,∑i=1mci≤n), where ci is the length of the i-th platform.

      Output

      If it is impossible to reach n+1 from 0, print NO in the first line. Otherwise, print YES in the first line and the array a of length n in the second line — the sequence of river cells (excluding cell 0 and cell n+1).

      If the cell i does not belong to any platform, ai should be 0. Otherwise, it should be equal to the index of the platform (1-indexed, platforms are numbered from 1 to m in order of input) to which the cell i belongs.

      Note that all ai equal to 1 should form a contiguous subsegment of the array a of length c1, all ai equal to 2 should form a contiguous subsegment of the array a of length c2, ..., all ai equal to m should form a contiguous subsegment of the array a of length cm. The leftmost position of 2 in a should be greater than the rightmost position of 1, the leftmost position of 3 in a should be greater than the rightmost position of 2, ..., the leftmost position of m in a should be greater than the rightmost position of m?1.

      See example outputs for better understanding.

      Examples

      input
      7 3 2
      1 2 1
      output
      YES
      0 1 0 2 2 0 3
      input
      10 1 11
      1
      output
      YES
      0 0 0 0 0 0 0 0 0 1
      input
      10 1 5
      2
      output
      YES
      0 0 0 0 1 1 0 0 0 0

      Note

      Consider the first example: the answer is [0,1,0,2,2,0,3]. The sequence of jumps you perform is 0→2→4→5→7→8.

      Consider the second example: it does not matter how to place the platform because you always can jump from 0 to 11.

      Consider the third example: the answer is [0,0,0,0,1,1,0,0,0,0]. The sequence of jumps you perform is 0→5→6→11.

      題意

      現在有長度為n的河,河上面你需要擺放m個木板,第i個木板的長度為c[i],木板與木板之間的擺放不能交叉,現在問你是否存在一個方案,能夠拜訪這些木板。

      題解

      貪心,我們假設所有木板都在最后面擺放。然后我開始跳躍,如果我腳下沒有木板,我就從后面拿一塊木板放在腳下即可。

      dp,dp[i][j]表示我現在在i位置,是站在第j塊木板的開始,然后開始轉移即可。

      代碼

      #include<bits/stdc++.h>
      using namespace std;
      const int maxn = 1005;
      int n,m,d;
      int c[maxn];
      int dp[maxn][maxn];
      int from[maxn][maxn];
      int plan[maxn];
      void print_plan(){
      	//plan[n]=m;
      	int now=n;
      	int j=m;
      	while(j>0){
      		for(int i=from[now][j];i<from[now][j]+c[j-1];i++){
      			plan[i]=j-1;
      		}
      		now=from[now][j];
      		j--;
      	}
      	for(int i=1;i<n;i++){
      		cout<<plan[i]<<" ";
      	}
      	cout<<endl;
      }
      int main(){
      	scanf("%d%d%d",&n,&m,&d);
      	for(int i=1;i<=m;i++){
      		scanf("%d",&c[i]);
      	}
      	c[0]=1;
      	n++;m++;c[m]=1;
      	dp[0][0]=1;
      	for(int i=1;i<=n;i++){
      		for(int j=1;j<=m;j++){
      			for(int k=1;k<=d;k++){
      				if(i-k-c[j-1]+1>=0&&dp[i-k-c[j-1]+1][j-1]){
      					dp[i][j]=1;
      					from[i][j]=i-k-c[j-1]+1;
      				}
      			}
      		}
      	}
      	if(dp[n][m]==1){
      		puts("YES");
      		print_plan();
      	}else{
      		puts("NO");
      	}
      }
      
      posted @ 2019-11-05 15:46  qscqesze  閱讀(403)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 免费无码中文字幕A级毛片| 怡红院一区二区三区在线| 日韩av综合免费在线| 一区二区三区四区黄色片| 中国CHINA体内裑精亚洲日本| 久久精品国产99国产精品澳门| 久久精品国产99国产精品澳门| 精品国产粉嫩一区二区三区| 隔壁老王国产在线精品| 欧美 亚洲 另类 丝袜 自拍 动漫| 天堂8中文在线最新版在线| 精品无码一区二区三区电影| 久久精品国产99久久久古代| 少妇被日自拍黄色三级网络| 精品免费看国产一区二区| 久女女热精品视频在线观看| 国产无遮挡性视频免费看| 精品2020婷婷激情五月| 狠狠躁日日躁夜夜躁欧美老妇| 97人妻人人揉人人躁人人| 亚洲国产精品综合久久网各 | 国产综合色一区二区三区| 亚洲熟妇自偷自拍另类| 欧美巨大极度另类| 久久久久夜夜夜精品国产| 搡老熟女老女人一区二区| 人成午夜免费视频无码| 鹤峰县| 精品一区二区三区蜜桃久| 国产女人18毛片水真多1| 色爱av综合网国产精品| 免费 黄 色 人成 视频 在 线| 爆乳女仆高潮在线观看| 尹人香蕉久久99天天拍欧美p7| 亚洲欧美综合中文| 国产女人看国产在线女人| 桃花岛亚洲成在人线AV| 国产女人被狂躁到高潮小说| 亚洲日韩成人无码不卡网站| 国产无遮挡免费视频免费| 国产91精品调教在线播放|