Skip to content

Commit 6a25767

Browse files
authored
Add files via upload
1 parent 9b79ed6 commit 6a25767

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

1932_정수 삼각형.ipynb

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 32,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"5\n",
13+
"7\n",
14+
"3 8\n",
15+
"8 1 0\n",
16+
"2 7 4 4\n",
17+
"4 5 2 6 5\n",
18+
"30\n"
19+
]
20+
}
21+
],
22+
"source": [
23+
"n = int(input())\n",
24+
"li = []\n",
25+
"for i in range(n):\n",
26+
" li.append(list(map(int, input().split())))\n",
27+
"\n",
28+
"if n > 1: \n",
29+
" li[1][0] += li[0][0]\n",
30+
" li[1][1] += li[0][0]\n",
31+
" for i in range(2, n):\n",
32+
" for j in range(i+1):\n",
33+
" if j == 0:\n",
34+
" li[i][0] += li[i-1][0]\n",
35+
" elif j == i:\n",
36+
" li[i][j] += li[i-1][j-1]\n",
37+
" else:\n",
38+
" li[i][j] += max(li[i-1][j], li[i-1][j-1])\n",
39+
"print(max(li[-1]))"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": []
48+
}
49+
],
50+
"metadata": {
51+
"kernelspec": {
52+
"display_name": "Python 3",
53+
"language": "python",
54+
"name": "python3"
55+
},
56+
"language_info": {
57+
"codemirror_mode": {
58+
"name": "ipython",
59+
"version": 3
60+
},
61+
"file_extension": ".py",
62+
"mimetype": "text/x-python",
63+
"name": "python",
64+
"nbconvert_exporter": "python",
65+
"pygments_lexer": "ipython3",
66+
"version": "3.6.8"
67+
}
68+
},
69+
"nbformat": 4,
70+
"nbformat_minor": 2
71+
}

0 commit comments

Comments
 (0)