Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0ms, 1A, 29行, 留念

Posted by vjubge4 at 2019-04-08 11:16:19 on Problem 1157
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int oo = 0x3f3f3f3f;
int V, F;
int Matrix[101][101];
int dp[101][101];

int main(){
    scanf("%d %d", &F, &V);
    for (int i = 1; i <= F; ++i) {
        for (int j = 1; j <= V; ++j) {
            scanf("%d", &Matrix[i][j]);
        }
    }
    for (int i = 0; i < 101; ++i) {
        fill(dp[i], dp[i] + 101, -oo);
    }
    dp[0][0] = 0;
    for (int i = 1; i <= F; ++i) {
        int Max_Val = *max_element(dp[i - 1], dp[i - 1] + i);
        for (int j = i; j <= V; ++j) {
            dp[i][j] = Max_Val + Matrix[i][j];
            Max_Val = max(Max_Val, dp[i - 1][j]);
        }
    }
    printf("%d\n", *max_element(dp[F], dp[F] + V + 1));
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator