SGU 104 Little Shop of Flowers (DP&打印路径)
2014-03-23 18:35
393 查看
http://acm.sgu.ru/problem.php?contest=0&problem=104
/*15ms,142KB*/ #include<bits/stdc++.h> using namespace std; const int mx = 105; int a[mx][mx], dp[mx][mx], f; void print(int i, int j) { if (i == 0) return; for (; dp[i][j] == dp[i][j - 1]; --j) ; print(i - 1, j - 1); printf("%d", j); if (i < f) putchar(' '); } void solve(int f, int v) { int i, j; for (i = 1; i <= f; ++i) for (j = i; j <= v - f + i; ++j) dp[i][j] = max(dp[i][j - 1], dp[i - 1][j - 1] + a[i][j]); printf("%d\n", dp[f][v] - f * 100); print(f, v); } int main() { int v, i, j; scanf("%d%d", &f, &v); for (i = 1; i <= f; ++i) for (j = 1; j <= v; ++j) scanf("%d", &a[i][j]), a[i][j] += 100; solve(f, v); return 0; }
相关文章推荐
- SGU104 Little shop of flowers(DP)
- SGU104 Little Shop of Flowers (DP)
- [SGU 104]Little Shop of Flowers(DP)
- Little shop of flowers - SGU 104 (DP)
- SGU 104 Little shop of flowers【DP】
- SGU 104 Little shop of flowers [dp]
- SGU 104 Little shop of flowers【DP】
- SGU 104 Little shop of flowers(DP)
- SGU 104 Little shop of flowers [dp]
- sgu 104 Little Shop of Flowers 动态规划(dp)题
- SGU 104 Little shop of flowers 经典DP
- SGU 104 Little shop of flowers(dp)
- SGU 104 Little shop of flowers 经典DP
- SGU104 Little shop of flowers (DP)
- SGU 104 Little shop of flowers(dp)
- Little shop of flowers - SGU 104 dp
- sgu 104 dp Little Shop of Flowers
- SGU 104 Little shop of flowers
- sgu 104 Little shop of flowers 解题报告及测试数据
- SGU104 Little Shop of Flowers