Submission #19517505


Source Code Expand

Copy
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  long long dp[N + 1][N + 1];
  fill_n(dp[0], N + 1, 0);
  for (int i = 1; i <= N; i++) {
    fill_n(dp[i], N + 1, 0);
    for (int j = 1; j <= i; j++) {
      long long a;
      cin >> a;
      dp[i][j] = a + max(dp[i - 1][j], dp[i - 1][j - 1]);
    }
  }
  long long ans = 0;
  for (int j = 1; j <= N; j++) ans = max(ans, dp[N][j]);
  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task D - 三角パズル
User hashiryo
Language C++ (GCC 9.2.1)
Score 100
Code Size 1728 Byte
Status AC
Exec Time 6 ms
Memory 3632 KB

Judge Result

Set Name sub1 sub2
Score / Max Score 50 / 50 50 / 50
Status
AC × 13
AC × 24
Set Name Test Cases
sub1 sub1/input_0.txt, sub1/input_1.txt, sub1/input_14.txt, sub1/input_15.txt, sub1/input_18.txt, sub1/input_19.txt, sub1/input_2.txt, sub1/input_20.txt, sub1/input_3.txt, sub1/input_4.txt, sub1/input_5.txt, sub1/input_6.txt, sub1/input_9.txt
sub2 sub2/input_0.txt, sub2/input_1.txt, sub2/input_10.txt, sub2/input_11.txt, sub2/input_12.txt, sub2/input_13.txt, sub2/input_14.txt, sub2/input_15.txt, sub2/input_16.txt, sub2/input_17.txt, sub2/input_18.txt, sub2/input_19.txt, sub2/input_2.txt, sub2/input_20.txt, sub2/input_21.txt, sub2/input_22.txt, sub2/input_23.txt, sub2/input_3.txt, sub2/input_4.txt, sub2/input_5.txt, sub2/input_6.txt, sub2/input_7.txt, sub2/input_8.txt, sub2/input_9.txt
Case Name Status Exec Time Memory
sub1/input_0.txt AC 6 ms 3504 KB
sub1/input_1.txt AC 2 ms 3448 KB
sub1/input_14.txt AC 2 ms 3452 KB
sub1/input_15.txt AC 3 ms 3552 KB
sub1/input_18.txt AC 2 ms 3560 KB
sub1/input_19.txt AC 3 ms 3508 KB
sub1/input_2.txt AC 2 ms 3548 KB
sub1/input_20.txt AC 2 ms 3624 KB
sub1/input_3.txt AC 2 ms 3448 KB
sub1/input_4.txt AC 2 ms 3584 KB
sub1/input_5.txt AC 3 ms 3584 KB
sub1/input_6.txt AC 4 ms 3620 KB
sub1/input_9.txt AC 3 ms 3588 KB
sub2/input_0.txt AC 2 ms 3520 KB
sub2/input_1.txt AC 2 ms 3448 KB
sub2/input_10.txt AC 5 ms 3532 KB
sub2/input_11.txt AC 2 ms 3544 KB
sub2/input_12.txt AC 4 ms 3520 KB
sub2/input_13.txt AC 3 ms 3460 KB
sub2/input_14.txt AC 3 ms 3580 KB
sub2/input_15.txt AC 2 ms 3508 KB
sub2/input_16.txt AC 2 ms 3540 KB
sub2/input_17.txt AC 3 ms 3628 KB
sub2/input_18.txt AC 2 ms 3592 KB
sub2/input_19.txt AC 2 ms 3512 KB
sub2/input_2.txt AC 2 ms 3548 KB
sub2/input_20.txt AC 2 ms 3512 KB
sub2/input_21.txt AC 2 ms 3524 KB
sub2/input_22.txt AC 2 ms 3472 KB
sub2/input_23.txt AC 2 ms 3460 KB
sub2/input_3.txt AC 2 ms 3580 KB
sub2/input_4.txt AC 2 ms 3496 KB
sub2/input_5.txt AC 2 ms 3440 KB
sub2/input_6.txt AC 3 ms 3452 KB
sub2/input_7.txt AC 2 ms 3528 KB
sub2/input_8.txt AC 2 ms 3632 KB
sub2/input_9.txt AC 2 ms 3512 KB