78分的新手……?

P1216 [USACO1.5] [IOI1994]数字三角形 Number Triangles

Pig3 @ 2024-08-17 11:19:39

#include <bits/stdc++.h>
using namespace std;

int main(){
    int r,a[1001][1001],ans[1001];cin>>r;
    for(int i = 1;i<=r;i++){
        for(int j = 1;j<=i;j++){
            cin>>a[i][j];
            a[i][j] += max(a[i-1][j],a[i-1][j-1]);
        }
    }
    for(int i = 0;i<r;i++){
        ans[i] = a[r][i];
    }
    sort(ans,ans+r);
    cout<<ans[r-1];
}

大佬看看?


by Pig3 @ 2024-08-25 11:34:15

OK了,谢谢各位大佬,此篇结


上一页 |