{"action":"opened","issue":{"url":"https://api.github.com/repos/CodeSang/Koreatech_study/issues/7","repository_url":"https://api.github.com/repos/CodeSang/Koreatech_study","labels_url":"https://api.github.com/repos/CodeSang/Koreatech_study/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/CodeSang/Koreatech_study/issues/7/comments","events_url":"https://api.github.com/repos/CodeSang/Koreatech_study/issues/7/events","html_url":"https://github.com/CodeSang/Koreatech_study/issues/7","id":172513424,"number":7,"title":"1246 온라인 판매 질문입니다.","user":{"login":"Jaeyeong-Lee","id":20218186,"avatar_url":"https://avatars.githubusercontent.com/u/20218186?v=3","gravatar_id":"","url":"https://api.github.com/users/Jaeyeong-Lee","html_url":"https://github.com/Jaeyeong-Lee","followers_url":"https://api.github.com/users/Jaeyeong-Lee/followers","following_url":"https://api.github.com/users/Jaeyeong-Lee/following{/other_user}","gists_url":"https://api.github.com/users/Jaeyeong-Lee/gists{/gist_id}","starred_url":"https://api.github.com/users/Jaeyeong-Lee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jaeyeong-Lee/subscriptions","organizations_url":"https://api.github.com/users/Jaeyeong-Lee/orgs","repos_url":"https://api.github.com/users/Jaeyeong-Lee/repos","events_url":"https://api.github.com/users/Jaeyeong-Lee/events{/privacy}","received_events_url":"https://api.github.com/users/Jaeyeong-Lee/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-22T17:50:56Z","updated_at":"2016-08-22T17:50:56Z","closed_at":null,"body":"`\r\n    \r\n    import java.util.*;\r\n\r\n    public class Main {\r\n\r\n\tScanner sc;\r\n\tint n, m;\r\n\tint arr[] = new int[1010];\r\n\tint max = 0;\r\n\tint min_h = 9876543;\r\n\r\n\tvoid input(){\r\n\t\tsc = new Scanner(System.in);\r\n\r\n\t\tn = sc.nextInt();\tm = sc.nextInt();\r\n\r\n\t\tfor(int i = 0; i < m; i++)\r\n\t\t\tarr[i] = sc.nextInt();\r\n\t}\r\n\r\n\tvoid process(){\r\n\r\n\t\tStack<Integer> st = new Stack<Integer>();\r\n\r\n\t\tst.push(0);\r\n\r\n\t\tfor(int i = 0; i < m; i++){\r\n\r\n\t\t\twhile( !st.isEmpty() && arr[st.peek()] > arr[i] ){\r\n\r\n\t\t\t\tint h = arr[st.pop()];\r\n\t\t\t\tint w = i;\r\n\r\n\r\n\t\t\t\tif( !st.isEmpty() ){\r\n\t\t\t\t\tw = i -1 - st.peek();\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// ?????\r\n\t\t\t\tif( w >= n ){\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tint ar = h*w;\r\n\r\n\t\t\t\tif( max <= ar ){\r\n\t\t\t\t\tmax = ar;\r\n\t\t\t\t\t\r\n\t\t\t\t\tif( min_h > h )\r\n\t\t\t\t\t\tmin_h = h;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tst.push(i);\r\n\r\n\t\t}\r\n\r\n\r\n\t\twhile(!st.isEmpty()){\r\n\r\n\t\t\tint h = arr[st.pop()];\r\n\t\t\tint w = m;\r\n\r\n\t\t\tif( !st.isEmpty() ){\r\n\t\t\t\tw = m -1 - st.peek();\r\n\t\t\t}\r\n\r\n\t\t\t// ?????\r\n\t\t\tif( w >= n ) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tint ar = h*w;\r\n\r\n\t\t\tif( max <= ar ){\r\n\t\t\t\tmax = ar;\r\n\t\t\t\tif( min_h > h )\r\n\t\t\t\t\tmin_h = h;\r\n\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tvoid output(){\r\n\t\tSystem.out.print(min_h+ \" \"+max);\r\n\t}\r\n\r\n\tpublic static void main(String args[]){\r\n\t\tMain m = new Main();\r\n\r\n\t\tm.input();\r\n\t\tm.process();\r\n\t\tm.output();\r\n\t}\r\n    }\r\n\r\n`\r\n\r\n수익은 최대로 올리면서, 달걀을 가장 낮은 가격으로 파는 문제인데요,\r\n\r\n히스토그램에서 가장 넓으면서, 가장 낮은 높이를 찾도록 프로그램을 짰습니다.\r\n\r\n\r\n고려해야 될 것이 //?????? 로 표시한 폭이 n 이상일때인데, 이 부분을 어떻게 처리해야할지 잘 모르겠습니다.\r\n\r\n스택을 쓰지 않고도 문제는 풀릴 것 같은데, \r\n이 방법으로 푸는 것은 힘들까요? 궁금합니다."}}
{"actor":{"display_login":"Jaeyeong-Lee"}}