传送门: http://poj.org/problem?id=3666 Making the Grade Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9468 Accepted: 4406 Description A straight dirt road connects two fields on FJ's farm, but it changes elevation more than FJ would lik…
解题关键:先由贪心的思想得出任何一个位置只能取1或者a[i],然后dp即可. #include<bits/stdc++.h> using namespace std; typedef long long ll; #define maxn 50002 ]; int main(){ int n; cin>>n; ;i<n;i++) cin>>a[i]; dp[][]=dp[][]=; ;i<n;i++){ dp[i][]=max(dp[i-][],dp[i-][…