Submission #19556232


Source Code Expand

Copy
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	int n; cin >> n;
	int a[n][n], dp[n][n];
	bzero(a, sizeof(a));
	bzero(dp, sizeof(dp));
	REP(i, n) REP(j, i+1) cin >> a[i][j];
	dp[0][0] = a[0][0];
	REP(i, n) REP(j, n) {
		if (i > 0)
			dp[i][j] = a[i][j] + dp[i-1][j];
		if (i > 0 && j > 0)
			dp[i][j] = max(dp[i][j], a[i][j] + dp[i-1][j-1]);
	}
	int res = 0;
	REP(i, n) res = max(res, dp[n-1][i]);
	cout << res << '\n';
	return 0;
}

Submission Info

Submission Time
Task D - 三角パズル
User solareenlo
Language C++ (GCC 9.2.1)
Score 100
Code Size 514 Byte
Status AC
Exec Time 10 ms
Memory 3640 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 10 ms 3436 KB
sub1/input_1.txt AC 2 ms 3568 KB
sub1/input_14.txt AC 2 ms 3504 KB
sub1/input_15.txt AC 2 ms 3632 KB
sub1/input_18.txt AC 2 ms 3600 KB
sub1/input_19.txt AC 2 ms 3440 KB
sub1/input_2.txt AC 2 ms 3372 KB
sub1/input_20.txt AC 2 ms 3576 KB
sub1/input_3.txt AC 3 ms 3520 KB
sub1/input_4.txt AC 2 ms 3580 KB
sub1/input_5.txt AC 2 ms 3412 KB
sub1/input_6.txt AC 2 ms 3436 KB
sub1/input_9.txt AC 2 ms 3384 KB
sub2/input_0.txt AC 2 ms 3568 KB
sub2/input_1.txt AC 2 ms 3564 KB
sub2/input_10.txt AC 3 ms 3392 KB
sub2/input_11.txt AC 2 ms 3592 KB
sub2/input_12.txt AC 2 ms 3532 KB
sub2/input_13.txt AC 2 ms 3580 KB
sub2/input_14.txt AC 2 ms 3432 KB
sub2/input_15.txt AC 3 ms 3524 KB
sub2/input_16.txt AC 3 ms 3640 KB
sub2/input_17.txt AC 3 ms 3636 KB
sub2/input_18.txt AC 2 ms 3632 KB
sub2/input_19.txt AC 2 ms 3380 KB
sub2/input_2.txt AC 1 ms 3548 KB
sub2/input_20.txt AC 2 ms 3552 KB
sub2/input_21.txt AC 3 ms 3636 KB
sub2/input_22.txt AC 2 ms 3456 KB
sub2/input_23.txt AC 2 ms 3428 KB
sub2/input_3.txt AC 2 ms 3564 KB
sub2/input_4.txt AC 2 ms 3436 KB
sub2/input_5.txt AC 2 ms 3380 KB
sub2/input_6.txt AC 2 ms 3600 KB
sub2/input_7.txt AC 3 ms 3528 KB
sub2/input_8.txt AC 2 ms 3544 KB
sub2/input_9.txt AC 2 ms 3432 KB