Submission #1726325


Source Code Expand

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
//constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);

int D[110][110];
int dp[110][110];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			cin >> D[i][j];
		}
	}
	dp[1][1] = D[1][1];
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			if (j == 1) {
				dp[i][j] = dp[i - 1][j] + D[i][j];
			}
			else if (j == i) {
				dp[i][j] = dp[i - 1][j - 1] + D[i][j];
			}
			else {
				dp[i][j] = max(dp[i - 1][j - 1] + D[i][j], dp[i - 1][j] + D[i][j]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[n][i]);
	}
	cout << ans << endl;
 }

Submission Info

Submission Time
Task D - 三角パズル
User M3_cp
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1299 Byte
Status AC
Exec Time 2 ms
Memory 256 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 1 ms 256 KB
sub1/input_1.txt AC 1 ms 256 KB
sub1/input_14.txt AC 1 ms 256 KB
sub1/input_15.txt AC 1 ms 256 KB
sub1/input_18.txt AC 1 ms 256 KB
sub1/input_19.txt AC 1 ms 256 KB
sub1/input_2.txt AC 1 ms 256 KB
sub1/input_20.txt AC 1 ms 256 KB
sub1/input_3.txt AC 1 ms 256 KB
sub1/input_4.txt AC 1 ms 256 KB
sub1/input_5.txt AC 1 ms 256 KB
sub1/input_6.txt AC 1 ms 256 KB
sub1/input_9.txt AC 1 ms 256 KB
sub2/input_0.txt AC 1 ms 256 KB
sub2/input_1.txt AC 1 ms 256 KB
sub2/input_10.txt AC 2 ms 256 KB
sub2/input_11.txt AC 2 ms 256 KB
sub2/input_12.txt AC 2 ms 256 KB
sub2/input_13.txt AC 2 ms 256 KB
sub2/input_14.txt AC 1 ms 256 KB
sub2/input_15.txt AC 1 ms 256 KB
sub2/input_16.txt AC 2 ms 256 KB
sub2/input_17.txt AC 2 ms 256 KB
sub2/input_18.txt AC 1 ms 256 KB
sub2/input_19.txt AC 1 ms 256 KB
sub2/input_2.txt AC 1 ms 256 KB
sub2/input_20.txt AC 1 ms 256 KB
sub2/input_21.txt AC 2 ms 256 KB
sub2/input_22.txt AC 2 ms 256 KB
sub2/input_23.txt AC 2 ms 256 KB
sub2/input_3.txt AC 1 ms 256 KB
sub2/input_4.txt AC 1 ms 256 KB
sub2/input_5.txt AC 1 ms 256 KB
sub2/input_6.txt AC 1 ms 256 KB
sub2/input_7.txt AC 2 ms 256 KB
sub2/input_8.txt AC 2 ms 256 KB
sub2/input_9.txt AC 1 ms 256 KB