Skip to content

Commit 7776ce6

Browse files
committed
백준 1문제 품
1 parent e88c71c commit 7776ce6

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

동적 계획법.ipynb

+80-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
"metadata": {},
287287
"outputs": [
288288
{
289-
"name": "stdin",
289+
"name": "stdout",
290290
"output_type": "stream",
291291
"text": [
292292
" 2\n",
@@ -332,11 +332,89 @@
332332
"print(dp[n])\n"
333333
]
334334
},
335+
{
336+
"cell_type": "markdown",
337+
"id": "7fde99ff",
338+
"metadata": {},
339+
"source": [
340+
"## 11\t11053\t가장 긴 증가하는 부분 수열\n",
341+
"LIS(Longest Increasing Subsequence)를 구하는 문제"
342+
]
343+
},
335344
{
336345
"cell_type": "code",
337-
"execution_count": null,
346+
"execution_count": 2,
338347
"id": "d0057fdb-83e3-4ca0-a55a-5e5dfe3d3921",
339348
"metadata": {},
349+
"outputs": [
350+
{
351+
"name": "stdout",
352+
"output_type": "stream",
353+
"text": [
354+
"20 10\n",
355+
"0\n",
356+
"1\n",
357+
"30 10\n",
358+
"0\n",
359+
"1\n",
360+
"30 20\n",
361+
"1\n",
362+
"2\n",
363+
"30 10\n",
364+
"2\n",
365+
"2\n",
366+
"20 10\n",
367+
"0\n",
368+
"1\n",
369+
"20 10\n",
370+
"1\n",
371+
"1\n",
372+
"50 10\n",
373+
"0\n",
374+
"1\n",
375+
"50 20\n",
376+
"1\n",
377+
"2\n",
378+
"50 10\n",
379+
"2\n",
380+
"2\n",
381+
"50 30\n",
382+
"2\n",
383+
"3\n",
384+
"50 20\n",
385+
"3\n",
386+
"3\n"
387+
]
388+
}
389+
],
390+
"source": [
391+
"# 어떤 수열을 입력 받는다\n",
392+
"# 목표는 긴 수열을 찾는것. \n",
393+
"# 각 자리의 수마다 검사를 해본다.\n",
394+
"\n",
395+
"# 10 20 10 30 20 50\n",
396+
"# 1 2 1 3 2 4\n",
397+
" \n",
398+
"n=int(input())\n",
399+
"dp=[1]*n\n",
400+
"arr=list(map(int,input().split()))\n",
401+
"\n",
402+
"for i in range(n):\n",
403+
" for j in range(i):\n",
404+
" if arr[i]>arr[j]: #전의 수보다 클경우만\n",
405+
" # print(arr[i],arr[j])\n",
406+
" # print(dp[i])\n",
407+
" dp[i]=max(dp[i],dp[j]+1)\n",
408+
" # print(dp[i])\n",
409+
" \n",
410+
"print(max(dp))\n"
411+
]
412+
},
413+
{
414+
"cell_type": "code",
415+
"execution_count": null,
416+
"id": "fca76945",
417+
"metadata": {},
340418
"outputs": [],
341419
"source": []
342420
}

0 commit comments

Comments
 (0)