Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define f(i,a,b) for(int i = (a); i <= (b); i++)
- using namespace std;
- const int INF = 2000000007;
- int A[10005], B[10005], DP[5005][5005], N;
- int main()
- {
- cin >> N;
- int ans = 0;
- f(i,1,N) cin >> A[i] >> B[i];
- f(i,0,N/2) f(j,0,N/2) DP[i][j] = INF;
- DP[0][0] = 0;
- f(j,0,N/2) f(i,0,j)
- {
- DP[i+1][j] = min(DP[i+1][j], DP[i][j] + A[i+j+1]);
- DP[i][j+1] = min(DP[i][j+1], DP[i][j] + B[i+j+1]);
- }
- cout << DP[N/2][N/2];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement