日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Little Red Riding Hood(动态规划)

發布時間:2023/12/15 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Little Red Riding Hood(动态规划) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目:

?Little Red Riding Hood

?

題目描述

? ? Once upon a time, there was a little girl. Her name was Little Red Riding Hood. One day, her grandma was ill. Little Red Riding Hood went to visit her. On the way, she met a big wolf. “That's a good idea.”,the big wolf thought. And he said to the Little Red Riding Hood, “Little Red Riding Hood, the flowers are so beautiful. Why not pick some to your grandma?” “Why didn't I think of that? Thank you.” Little Red Riding Hood said.

? ? Then Little Red Riding Hood went to the grove to pick flowers. There were n flowers, each flower had a beauty degree a[i]. These flowers arrayed one by one in a row. The magic was that after Little Red Riding Hood pick a flower, the flowers which were exactly or less than d distances to it are quickly wither and fall, in other words, the beauty degrees of those flowers changed to zero. Little Red Riding Hood was very smart, and soon she took the most beautiful flowers to her grandma’s house, although she didn’t know the big wolf was waiting for her. Do you know the sum of beauty degrees of those flowers which Little Red Riding Hood pick??

輸入

? ? The first line input a positive integer T (1≤T≤100), indicates the number of test cases. Next, each test case occupies two lines. The first line of them input two positive integer n and

k (2 <= n <= 10^5 ) ,1 <= ?k <= n ),?the second line of them input n positive integers a (1<=a <=10^5)

輸出

? ? Each group of outputs occupies one line and there are one number indicates the sum of the largest beauty degrees of flowers Little Red Riding Hood can pick.?

樣例輸入

1 3 1 2 1 3

樣例輸出

5

?

題目描述:

動態規劃題,設dp[i]為到拿取第i個位置的最大價值,推出轉移方程即可。

?

代碼:

#include<stdio.h> #include<string.h> int a,b,aa[100010],c[100010],d[100010],f[100010]; int main() {int i,j,k;int t;scanf("%d",&t);while(t--){scanf("%d%d",&a,&b);memset(aa,0,sizeof(aa));memset(c,0,sizeof(c));memset(d,0,sizeof(d));memset(f,0,sizeof(f));int max = 0,max1 = 0;for(i = 1; i <= a;i ++){scanf("%d",&aa[i]);if(i -b-1 >= 1){if(max < aa[i -b-1]){max = aa[i -b-1];}}c[i] = max;if(i - b >= 1){if(max1 < aa[i - 1]){max1 = aa[i - 1];}}d[i] = max1; // printf("%d %d\n",c[i],d[i]);}f[1] = aa[1];int ma=0,ma1=0;for(i = 1;i <=a;i++){if(i-b-1>=1)if(ma<f[i-b-1])ma = f[i-b-1]; // ma1 = 0; // if(i-b>=1){ // for(j=i;j<i+b;j++) // if(ma1<f[j]) // ma1 = f[j]; // }f[i] = ma+aa[i]>f[i-1]?ma+aa[i]:f[i-1]; // printf("!%d\n",f[i]);}printf("%d\n",f[a]);}return 0; }

?

?

?

?

?

總結

以上是生活随笔為你收集整理的Little Red Riding Hood(动态规划)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产欧美一区二区三区在线看蜜臀 | 91麻豆精品国产91 | 日产精品一区 | 黄色三级网 | 欧美激情精品久久久久久蜜臀 | 日韩一级色片 | 女人扒开腿让男人捅爽 | 午夜快播| 91麻豆映画传媒 | 国产亚洲欧美日韩高清 | 欧美日韩成人精品 | 亚欧综合在线 | 日韩一区二区免费在线观看 | 欧美日韩在线二区 | 欧美91精品久久久久国产性生爱 | 操欧美美女 | 四虎精品在永久在线观看 | 少妇看片 | 色婷婷在线观看视频 | 欧美在线色视频 | 午夜小福利 | 免费萌白酱国产一区二区三区 | 久久久久久久久免费 | 国产天堂视频 | 超碰在线cao | 成人一级免费视频 | 国产九九九九 | 成人a毛片 | 伊人色综合久久久 | 欧美性受xxxx黑人xyx性爽 | 午夜影院体验区 | a视频在线播放 | 国产精品一级无码 | 免费国产视频在线观看 | 免费三片在线观看网站v888 | 激情av中文字幕 | 亚洲色图视频网站 | 精品亚洲一区二区三区 | www.色在线| 国产xxxx孕妇 | 韩日产理伦片在线观看 | 欧美另类xxxx | 黄色av免费在线观看 | 久久性生活 | 黄片毛片在线免费观看 | 噼里啪啦国语高清 | 亚洲一区二区三区影院 | 999久久久久| av一区三区 | 亚洲成人a v | 国产精品传媒在线观看 | 久久久久久久久久久丰满 | 大胸喷奶水www视频妖精网站 | 天使色吧 | 国产伦精品一区二区三区在线观看 | 成人无码www在线看免费 | 伊人久久精品视频 | 先锋影音av在线资源 | 激情婷婷综合网 | www.youjizz.com亚洲 | 西西午夜影院 | 国产同性人妖ts口直男 | 水牛影视av一区二区免费 | 国产对白刺激视频 | 国产做爰免费观看视频 | 久久妇女 | 久久精品人人爽 | 久久综合一区二区三区 | 国产裸体美女永久免费无遮挡 | 69日影院 | 亚洲精品福利在线 | 男人av的天堂 | 美女高潮视频在线观看 | 色网在线免费观看 | 中文字幕精品一区 | 老女人人体欣赏a√s | 国产精品高潮AV无码 | 欧美激情一区二区三区p站 欧美mv日韩mv国产网站app | 在线中文字幕视频 | 久久久久久艹 | 成人精品二区 | 影音先锋亚洲成aⅴ人在 | 污漫在线观看 | 污视频软件在线观看 | 91丨porny丨在线 | 国产精品免费大片 | 黄色成人影视 | av成人在线观看 | av在线一区二区三区 | 九九啪| 毛片网络| 日韩av在线播放网址 | 日韩二区视频 | 少妇人妻一区二区 | 日本成人片网站 | 亚洲色图20p| 麻豆网址 | 亚洲黄色录像 | 亚洲视频自拍 |