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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

P1799 数列_NOI导刊2010提高(06)

發布時間:2025/7/25 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 P1799 数列_NOI导刊2010提高(06) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

P1799 數列_NOI導刊2010提高(06)
f[i][j]表示前i個數刪去j個數得到的最大價值。
if(i-j==x)
f[i][j]=max(f[i][j],f[i-1][j]+1);
else
f[i][j]=max(f[i][j],f[i-1][j]);
f[i][j]=max(f[i-1][j-1],f[i][j]);

1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<algorithm> 5 #include<cmath> 6 #include<ctime> 7 #include<set> 8 #include<cstring> 9 #define inf INT_MAX 10 #define For(i,a,b) for(register int i=a;i<=b;i++) 11 #define p(a) putchar(a) 12 #define g() getchar() 13 //by war 14 //2017.10.26 15 using namespace std; 16 int a[1010]; 17 int f[1010][1010]; 18 int x; 19 int ans; 20 int n; 21 void in(int &x) 22 { 23 int y=1; 24 char c=g();x=0; 25 while(c<'0'||c>'9') 26 { 27 if(c=='-') 28 y=-1; 29 c=g(); 30 } 31 while(c<='9'&&c>='0')x=x*10+c-'0',c=g(); 32 x*=y; 33 } 34 void o(int x) 35 { 36 if(x<0) 37 { 38 p('-'); 39 x=-x; 40 } 41 if(x>9)o(x/10); 42 p(x%10+'0'); 43 } 44 int main() 45 { 46 in(n); 47 For(i,1,n) 48 { 49 in(x); 50 For(j,0,i-1) 51 { 52 if(i-j==x) 53 f[i][j]=max(f[i][j],f[i-1][j]+1); 54 else 55 f[i][j]=max(f[i][j],f[i-1][j]); 56 f[i][j]=max(f[i-1][j-1],f[i][j]); 57 } 58 } 59 For(i,0,n-1) 60 ans=max(ans,f[n][i]); 61 o(ans); 62 return 0; 63 }

?

轉載于:https://www.cnblogs.com/war1111/p/7742228.html

總結

以上是生活随笔為你收集整理的P1799 数列_NOI导刊2010提高(06)的全部內容,希望文章能夠幫你解決所遇到的問題。

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