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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

TC SRM 593 DIV2 1000

發布時間:2023/12/19 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TC SRM 593 DIV2 1000 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

很棒的DP,不過沒想出,看題解了。。思維很重要。

1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <vector> 5 #include <cmath> 6 #include <algorithm> 7 using namespace std; 8 int dp[1000010]; 9 int sum[51]; 10 class MayTheBestPetWin 11 { 12 public : 13 int calc(vector <int> A, vector <int> B) 14 { 15 int i,j,s1,s2; 16 s1 = s2 = 0; 17 memset(dp,-1,sizeof(dp)); 18 dp[0] = 0; 19 for(i = 0;i < A.size();i ++) 20 { 21 sum[i] = A[i] + B[i]; 22 } 23 for(i = 0;i < A.size();i ++) 24 { 25 s1 += A[i]; 26 s2 += B[i]; 27 for(j = 1000000;j >= sum[i];j --) 28 { 29 if(dp[j-sum[i]] != -1&&dp[j] <= dp[j-sum[i]] + sum[i]) 30 { 31 dp[j] = dp[j-sum[i]] + sum[i]; 32 } 33 } 34 35 } 36 int minz = 10000000,t1,t2; 37 for(i = 1;i <= 1000000;i ++) 38 { 39 if(dp[i] != -1) 40 { 41 t1 = abs(s1-i); 42 t2 = abs(s2-i); 43 minz = min(minz,max(t1,t2)); 44 } 45 } 46 return minz; 47 } 48 };

?

轉載于:https://www.cnblogs.com/naix-x/p/3354256.html

總結

以上是生活随笔為你收集整理的TC SRM 593 DIV2 1000的全部內容,希望文章能夠幫你解決所遇到的問題。

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