9 solutions
-
0
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef pair<int, int> PII; using ll = long long; using ULL = unsigned long long; const int N = 1e7 + 5; int n,a[1010][1010]; inline void solve() { cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) cin >> a[i][j]; for (int i = n - 1; i >= 1; i--) { for (int j = 1; j <= i; j++) { a[i][j] = max(a[i][j]+a[i+1][j],a[i][j]+a[i+1][j+1]); } } cout << a[1][1] << endl; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int _ = 1; //int _; cin >> _; while (_--) solve(); return 0; }
Information
- ID
- 87
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 247
- Accepted
- 98
- Uploaded By