<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>정렬 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%EC%A0%95%EB%A0%AC/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Wed, 30 Jul 2025 07:13:31 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>정렬 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Swagger/OpenAPI for .NET</title>
		<link>https://lycos7560.com/c/asp-net/swagger-openapi-for-net/40167/</link>
					<comments>https://lycos7560.com/c/asp-net/swagger-openapi-for-net/40167/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 18 Jun 2025 07:06:11 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET6]]></category>
		<category><![CDATA[.NET7]]></category>
		<category><![CDATA[.NET8]]></category>
		<category><![CDATA[Accept헤더]]></category>
		<category><![CDATA[API가이드라인]]></category>
		<category><![CDATA[API계약]]></category>
		<category><![CDATA[API명세]]></category>
		<category><![CDATA[API문서화]]></category>
		<category><![CDATA[API버전관리]]></category>
		<category><![CDATA[API설계]]></category>
		<category><![CDATA[API테스트]]></category>
		<category><![CDATA[Application Insights]]></category>
		<category><![CDATA[appsettings]]></category>
		<category><![CDATA[ASP.NET Core]]></category>
		<category><![CDATA[Bearer토큰]]></category>
		<category><![CDATA[CI/CD]]></category>
		<category><![CDATA[Content-Type]]></category>
		<category><![CDATA[CORS]]></category>
		<category><![CDATA[DTO패턴]]></category>
		<category><![CDATA[FluentValidation]]></category>
		<category><![CDATA[FromBody]]></category>
		<category><![CDATA[FromQuery]]></category>
		<category><![CDATA[HTTP메서드]]></category>
		<category><![CDATA[HTTP상태코드]]></category>
		<category><![CDATA[Identity]]></category>
		<category><![CDATA[IdentityServer]]></category>
		<category><![CDATA[Interactive Documentation]]></category>
		<category><![CDATA[JSON Schema]]></category>
		<category><![CDATA[JSON직렬화]]></category>
		<category><![CDATA[JWT인증]]></category>
		<category><![CDATA[NuGet패키지]]></category>
		<category><![CDATA[OAuth2]]></category>
		<category><![CDATA[OpenAPI]]></category>
		<category><![CDATA[OpenAPI Specification]]></category>
		<category><![CDATA[ProducesResponseType]]></category>
		<category><![CDATA[Program.cs]]></category>
		<category><![CDATA[REST API]]></category>
		<category><![CDATA[RESTful설계]]></category>
		<category><![CDATA[Swagger]]></category>
		<category><![CDATA[SwaggerGen]]></category>
		<category><![CDATA[SwaggerUI]]></category>
		<category><![CDATA[Swashbuckle]]></category>
		<category><![CDATA[XML주석]]></category>
		<category><![CDATA[개발도구]]></category>
		<category><![CDATA[개발생산성]]></category>
		<category><![CDATA[개발환경]]></category>
		<category><![CDATA[검색]]></category>
		<category><![CDATA[결과필터]]></category>
		<category><![CDATA[구성관리]]></category>
		<category><![CDATA[권한부여]]></category>
		<category><![CDATA[글로벌필터]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[네이밍컨벤션]]></category>
		<category><![CDATA[단위테스트]]></category>
		<category><![CDATA[데이터어노테이션]]></category>
		<category><![CDATA[디버깅]]></category>
		<category><![CDATA[라우팅]]></category>
		<category><![CDATA[로깅]]></category>
		<category><![CDATA[리플렉션]]></category>
		<category><![CDATA[린팅]]></category>
		<category><![CDATA[메타데이터추출]]></category>
		<category><![CDATA[모니터링]]></category>
		<category><![CDATA[모델바인딩]]></category>
		<category><![CDATA[문서화자동화]]></category>
		<category><![CDATA[미들웨어]]></category>
		<category><![CDATA[미들웨어파이프라인]]></category>
		<category><![CDATA[백엔드개발]]></category>
		<category><![CDATA[보안설정]]></category>
		<category><![CDATA[사용량추적]]></category>
		<category><![CDATA[상태코드]]></category>
		<category><![CDATA[서비스등록]]></category>
		<category><![CDATA[성능분석]]></category>
		<category><![CDATA[성능최적화]]></category>
		<category><![CDATA[순환참조]]></category>
		<category><![CDATA[스키마생성]]></category>
		<category><![CDATA[스키마필터]]></category>
		<category><![CDATA[스테이징환경]]></category>
		<category><![CDATA[액션메서드]]></category>
		<category><![CDATA[액션필터]]></category>
		<category><![CDATA[에러핸들링]]></category>
		<category><![CDATA[역할기반접근제어]]></category>
		<category><![CDATA[예외처리]]></category>
		<category><![CDATA[오류처리]]></category>
		<category><![CDATA[요청응답]]></category>
		<category><![CDATA[웹API]]></category>
		<category><![CDATA[유효성검사]]></category>
		<category><![CDATA[응답타입]]></category>
		<category><![CDATA[의존성주입]]></category>
		<category><![CDATA[인증통합]]></category>
		<category><![CDATA[인증필터]]></category>
		<category><![CDATA[자동문서화]]></category>
		<category><![CDATA[자동화배포]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[정적분석]]></category>
		<category><![CDATA[제네릭타입]]></category>
		<category><![CDATA[지속적통합]]></category>
		<category><![CDATA[컨트롤러]]></category>
		<category><![CDATA[코드리뷰]]></category>
		<category><![CDATA[코드퍼스트]]></category>
		<category><![CDATA[코드품질]]></category>
		<category><![CDATA[클레임기반인증]]></category>
		<category><![CDATA[타입안전성]]></category>
		<category><![CDATA[텔레메트리]]></category>
		<category><![CDATA[통합테스트]]></category>
		<category><![CDATA[트러블슈팅]]></category>
		<category><![CDATA[팀협업]]></category>
		<category><![CDATA[파라미터바인딩]]></category>
		<category><![CDATA[페이징]]></category>
		<category><![CDATA[프로덕션배포]]></category>
		<category><![CDATA[프론트엔드백엔드]]></category>
		<category><![CDATA[필터링]]></category>
		<category><![CDATA[환경변수]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=40167</guid>

					<description><![CDATA[<p>📖 Swagger(스웨거)란 무엇인가? Swagger는 현재 OpenAPI Specification (OAS)라는 이름으로 표준화된 RESTful API 명세 및 문서화 도구입니다. 2015년 SmartBear Software에서 OpenAPI Initiative에 기증한 후, 현재는 Linux Foundation 산하에서 관리되고 있습니다. 핵심 개념 🎯 Swagger가 필요한 이유 1. 개발 생산성 향상 2. 팀 협업 효율성 3. 운영 및 테스트 📦 Swashbuckle.AspNetCore 아키텍처 Swashbuckle.AspNetCore는 .NET에서 Swagger/OpenAPI를 구현하는 가장 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/c/asp-net/swagger-openapi-for-net/40167/">Swagger/OpenAPI for .NET</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-aee946f9      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#swagger스웨거란-무엇인가" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4d6.png" alt="📖" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger(스웨거)란 무엇인가?</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#핵심-개념" class="uagb-toc-link__trigger">핵심 개념</a></li></ul></li><li class="uagb-toc__list"><a href="#swagger가-필요한-이유" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3af.png" alt="🎯" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger가 필요한 이유</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-개발-생산성-향상" class="uagb-toc-link__trigger">1. 개발 생산성 향상</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#2-팀-협업-효율성" class="uagb-toc-link__trigger">2. 팀 협업 효율성</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#3-운영-및-테스트" class="uagb-toc-link__trigger">3. 운영 및 테스트</a></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#swashbuckleaspnetcore-아키텍처" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e6.png" alt="📦" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swashbuckle.AspNetCore 아키텍처</a><li class="uagb-toc__list"><a href="#net-6-프로젝트에서-swagger-구성" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> .NET 6+ 프로젝트에서 Swagger 구성</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-패키지-설치" class="uagb-toc-link__trigger">1. 패키지 설치</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#2-기본-구성-programcs" class="uagb-toc-link__trigger">2. 기본 구성 (Program.cs)</a></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#swaggergen의-동작-원리" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> SwaggerGen의 동작 원리</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#생성되는-openapi-문서-예시" class="uagb-toc-link__trigger">생성되는 OpenAPI 문서 예시</a></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#swagger-ui-고급-활용" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c4.png" alt="📄" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger UI 고급 활용</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#주요-기능" class="uagb-toc-link__trigger">주요 기능</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#커스터마이징-옵션" class="uagb-toc-link__trigger">커스터마이징 옵션</a></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#실무-필수-확장-기능" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 실무 필수 확장 기능</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-xml-주석-통합" class="uagb-toc-link__trigger">1. XML 주석 통합</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#2-jwt-bearer-인증-통합" class="uagb-toc-link__trigger">2. JWT Bearer 인증 통합</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#3-api-버전-관리" class="uagb-toc-link__trigger">3. API 버전 관리</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#4-사용자-정의-스키마-필터" class="uagb-toc-link__trigger">4. 사용자 정의 스키마 필터</a></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#성능-최적화-및-모범-사례" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ca.png" alt="📊" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 성능 최적화 및 모범 사례</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#1-프로덕션-환경-고려사항" class="uagb-toc-link__trigger">1. 프로덕션 환경 고려사항</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#2-대용량-api-문서-최적화" class="uagb-toc-link__trigger">2. 대용량 API 문서 최적화</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#3-보안-강화" class="uagb-toc-link__trigger">3. 보안 강화</a></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#트러블슈팅-가이드" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 트러블슈팅 가이드</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#일반적인-문제와-해결책" class="uagb-toc-link__trigger">일반적인 문제와 해결책</a></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#모니터링-및-분석" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c8.png" alt="📈" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 모니터링 및 분석</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#application-insights-통합" class="uagb-toc-link__trigger">Application Insights 통합</a></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li><li class="uagb-toc__list"><a href="#요약-및-베스트-프랙티스" class="uagb-toc-link__trigger"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약 및 베스트 프랙티스</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#핵심-도구-정리" class="uagb-toc-link__trigger">핵심 도구 정리</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#개발팀을-위한-권장사항" class="uagb-toc-link__trigger">개발팀을 위한 권장사항</a></ul></ul></ul></ul></ul></ul></ul></ul></ul></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4d6.png" alt="📖" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger(스웨거)란 무엇인가?</h2>



<p><strong>Swagger</strong>는 현재 OpenAPI Specification (OAS)라는 이름으로 표준화된 <strong>RESTful API 명세 및 문서화 도구</strong>입니다. </p>



<p>2015년 SmartBear Software에서 OpenAPI Initiative에 기증한 후, 현재는 Linux Foundation 산하에서 관리되고 있습니다.</p>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">핵심 개념</h3>



<ul class="wp-block-list">
<li><strong>API 명세의 표준화</strong>: REST API의 엔드포인트, 파라미터, 응답 구조를 JSON/YAML 형식으로 정의</li>



<li><strong>Code-First 접근</strong>: 소스코드로부터 API 문서를 자동 생성하여 문서와 구현 간 불일치 방지</li>



<li><strong>Interactive Documentation</strong>: 브라우저에서 직접 API를 테스트할 수 있는 UI 제공</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f3af.png" alt="🎯" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger가 필요한 이유</h2>



<h3 class="wp-block-heading">1. 개발 생산성 향상</h3>



<ul class="wp-block-list">
<li><strong>자동 문서화</strong>: 수동으로 API 문서를 작성하고 유지보수하는 비용 절약</li>



<li><strong>실시간 동기화</strong>: 코드 변경 시 문서가 자동으로 업데이트</li>



<li><strong>타입 안전성</strong>: .NET의 강타입 시스템을 활용한 정확한 스키마 생성</li>
</ul>



<h3 class="wp-block-heading">2. 팀 협업 효율성</h3>



<ul class="wp-block-list">
<li><strong>프론트엔드-백엔드 협업</strong>: 명확한 API 계약 정의를 통한 병렬 개발 지원</li>



<li><strong>API 계약 테스트</strong>: 구현 전 API 설계 검증 가능</li>



<li><strong>버전 관리</strong>: API 변경사항 추적 및 하위 호환성 관리</li>
</ul>



<h3 class="wp-block-heading">3. 운영 및 테스트</h3>



<ul class="wp-block-list">
<li><strong>통합 테스트</strong>: CI/CD 파이프라인에서 자동화된 API 테스트</li>



<li><strong>모니터링</strong>: API 사용 패턴 분석 및 성능 모니터링 기반 제공</li>
</ul>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4e6.png" alt="📦" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swashbuckle.AspNetCore 아키텍처</h2>



<p>Swashbuckle.AspNetCore는 .NET에서 Swagger/OpenAPI를 구현하는 가장 널리 사용되는 라이브러리입니다.</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>패키지</th><th>역할</th><th>주요 기능</th></tr></thead><tbody><tr><td><code>Swashbuckle.AspNetCore.Swagger</code></td><td>OpenAPI 문서 생성 엔진</td><td>JSON/YAML 형식의 OpenAPI 명세 생성</td></tr><tr><td><code>Swashbuckle.AspNetCore.SwaggerGen</code></td><td>코드 분석 및 메타데이터 추출</td><td>리플렉션을 통한 컨트롤러/액션 분석</td></tr><tr><td><code>Swashbuckle.AspNetCore.SwaggerUI</code></td><td>웹 UI 렌더링</td><td>인터랙티브한 API 문서 및 테스트 인터페이스</td></tr></tbody></table></figure>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f6e0.png" alt="🛠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> .NET 6+ 프로젝트에서 Swagger 구성</h2>



<h3 class="wp-block-heading">1. 패키지 설치</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group=""># Package Manager Console
Install-Package Swashbuckle.AspNetCore

# .NET CLI
dotnet add package Swashbuckle.AspNetCore
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">2. 기본 구성 (Program.cs)</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var builder = WebApplication.CreateBuilder(args);

// 컨트롤러 서비스 등록
builder.Services.AddControllers();

// Swagger 서비스 등록
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
    options.SwaggerDoc("v1", new OpenApiInfo
    {
        Version = "v1",
        Title = "My API",
        Description = "ASP.NET Core Web API for demonstration",
        Contact = new OpenApiContact
        {
            Name = "Developer Name",
            Email = "developer@example.com"
        }
    });
});

var app = builder.Build();

// 개발 환경에서만 Swagger 활성화
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI(options =>
    {
        options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
        options.RoutePrefix = string.Empty; // 루트 경로에서 Swagger UI 제공
    });
}

app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

app.Run();
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f50d.png" alt="🔍" class="wp-smiley" style="height: 1em; max-height: 1em;" /> SwaggerGen의 동작 원리</h2>



<p>SwaggerGen은 다음과 같은 과정을 통해 OpenAPI 문서를 생성합니다:</p>



<ol class="wp-block-list">
<li><strong>어셈블리 스캔</strong>: 등록된 컨트롤러와 액션 메서드 탐색</li>



<li><strong>메타데이터 추출</strong>: 라우트, HTTP 메서드, 파라미터, 반환 타입 분석</li>



<li><strong>스키마 생성</strong>: .NET 타입을 JSON Schema로 변환</li>



<li><strong>문서 조합</strong>: OpenAPI 3.0 사양에 맞는 JSON 문서 생성</li>
</ol>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">생성되는 OpenAPI 문서 예시</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">{
  "openapi": "3.0.1",
  "info": {
    "title": "My API",
    "version": "v1"
  },
  "paths": {
    "/api/products": {
      "get": {
        "tags": ["Products"],
        "summary": "제품 목록 조회",
        "responses": {
          "200": {
            "description": "성공",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "format": "int32" },
          "name": { "type": "string", "nullable": true }
        }
      }
    }
  }
}
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1378" height="1299" src="https://lycos7560.com/wp-content/uploads/2025/07/image-19.png" alt="" class="wp-image-40168" srcset="https://lycos7560.com/wp-content/uploads/2025/07/image-19.png 1378w, https://lycos7560.com/wp-content/uploads/2025/07/image-19-300x283.png 300w, https://lycos7560.com/wp-content/uploads/2025/07/image-19-768x724.png 768w" sizes="(max-width: 1378px) 100vw, 1378px" /></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c4.png" alt="📄" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Swagger UI 고급 활용</h2>



<p>Swagger UI는 생성된 OpenAPI 문서를 기반으로 다음 기능을 제공합니다:</p>



<h3 class="wp-block-heading">주요 기능</h3>



<ul class="wp-block-list">
<li><strong>HTTP 메서드별 분류</strong>: GET, POST, PUT, DELETE 등 시각적 구분</li>



<li><strong>스키마 검증</strong>: 요청/응답 데이터 구조 실시간 검증</li>



<li><strong>Try it Out</strong>: 브라우저에서 직접 API 호출 및 결과 확인</li>



<li><strong>모델 정의</strong>: 복잡한 객체 구조의 시각적 표현</li>



<li><strong>인증 통합</strong>: 다양한 인증 방식 지원 (Bearer, API Key 등)</li>
</ul>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">커스터마이징 옵션</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">app.UseSwaggerUI(options =>
{
    options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
    options.DocumentTitle = "My API Documentation";
    options.DefaultModelsExpandDepth(2);
    options.DefaultModelRendering(ModelRendering.Model);
    options.DisplayRequestDuration();
    options.EnableDeepLinking();
    options.EnableFilter();
    options.ShowExtensions();
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 실무 필수 확장 기능</h2>



<h3 class="wp-block-heading">1. XML 주석 통합</h3>



<p>프로젝트 파일 설정:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="xml" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;PropertyGroup>
  &lt;GenerateDocumentationFile>true&lt;/GenerateDocumentationFile>
  &lt;NoWarn>$(NoWarn);1591&lt;/NoWarn>
&lt;/PropertyGroup>
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>Program.cs 구성:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">builder.Services.AddSwaggerGen(options =>
{
    var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
    options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
    
    // 상속된 XML 주석 포함
    options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, "MyModels.xml"));
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>컨트롤러 예시:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">/// &lt;summary>
/// 제품 관리 API
/// &lt;/summary>
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
    /// &lt;summary>
    /// 제품 목록을 조회합니다.
    /// &lt;/summary>
    /// &lt;param name="pageSize">페이지당 항목 수 (기본값: 10)&lt;/param>
    /// &lt;returns>제품 목록&lt;/returns>
    /// &lt;response code="200">성공적으로 조회됨&lt;/response>
    /// &lt;response code="400">잘못된 요청 파라미터&lt;/response>
    [HttpGet]
    [ProducesResponseType(typeof(IEnumerable&lt;Product>), StatusCodes.Status200OK)]
    [ProducesResponseType(StatusCodes.Status400BadRequest)]
    public async Task&lt;ActionResult&lt;IEnumerable&lt;Product>>> GetProducts(
        [FromQuery] int pageSize = 10)
    {
        // 구현 로직
    }
}
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">2. JWT Bearer 인증 통합</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">builder.Services.AddSwaggerGen(options =>
{
    options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
    {
        Name = "Authorization",
        Type = SecuritySchemeType.Http,
        Scheme = "Bearer",
        BearerFormat = "JWT",
        In = ParameterLocation.Header,
        Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\""
    });

    options.AddSecurityRequirement(new OpenApiSecurityRequirement
    {
        {
            new OpenApiSecurityScheme
            {
                Reference = new OpenApiReference
                {
                    Type = ReferenceType.SecurityScheme,
                    Id = "Bearer"
                }
            },
            Array.Empty&lt;string>()
        }
    });
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">3. API 버전 관리</h3>



<p>패키지 설치:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">dotnet add package Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p>구성:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">builder.Services.AddApiVersioning(options =>
{
    options.DefaultApiVersion = new ApiVersion(1, 0);
    options.AssumeDefaultVersionWhenUnspecified = true;
    options.ApiVersionReader = ApiVersionReader.Combine(
        new UrlSegmentApiVersionReader(),
        new HeaderApiVersionReader("X-Version"),
        new MediaTypeApiVersionReader("ver"));
});

builder.Services.AddVersionedApiExplorer(setup =>
{
    setup.GroupNameFormat = "'v'VVV";
    setup.SubstituteApiVersionInUrl = true;
});

builder.Services.AddSwaggerGen();
builder.Services.ConfigureOptions&lt;ConfigureSwaggerOptions>();
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">4. 사용자 정의 스키마 필터</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public class EnumSchemaFilter : ISchemaFilter
{
    public void Apply(OpenApiSchema schema, SchemaFilterContext context)
    {
        if (context.Type.IsEnum)
        {
            schema.Enum.Clear();
            Enum.GetNames(context.Type)
                .ToList()
                .ForEach(name => schema.Enum.Add(new OpenApiString(name)));
        }
    }
}

// 등록
builder.Services.AddSwaggerGen(options =>
{
    options.SchemaFilter&lt;EnumSchemaFilter>();
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4ca.png" alt="📊" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 성능 최적화 및 모범 사례</h2>



<h3 class="wp-block-heading">1. 프로덕션 환경 고려사항</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">// 조건부 Swagger 활성화
if (app.Environment.IsDevelopment() || app.Environment.IsStaging())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

// 또는 구성 기반 활성화
if (builder.Configuration.GetValue&lt;bool>("EnableSwagger"))
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
</pre>



<h3 class="wp-block-heading">2. 대용량 API 문서 최적화</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">builder.Services.AddSwaggerGen(options =>
{
    // 불필요한 스키마 제외
    options.SchemaFilter&lt;ExcludeInternalTypesFilter>();
    
    // 문서 압축
    options.EnableAnnotations();
    
    // 메모리 사용량 최적화
    options.UseAllOfToExtendReferenceSchemas();
    options.UseOneOfForPolymorphism();
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">3. 보안 강화</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">app.UseSwagger(options =>
{
    // JSON 문서 접근 제한
    options.PreSerializeFilters.Add((swagger, httpReq) =>
    {
        if (!httpReq.Headers.ContainsKey("X-API-Key"))
        {
            throw new UnauthorizedAccessException();
        }
    });
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 트러블슈팅 가이드</h2>



<h3 class="wp-block-heading">일반적인 문제와 해결책</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>문제</th><th>원인</th><th>해결방법</th></tr></thead><tbody><tr><td>XML 주석이 표시되지 않음</td><td>XML 파일 경로 오류</td><td>빌드 출력 디렉토리 확인 및 경로 수정</td></tr><tr><td>복잡한 제네릭 타입 오류</td><td>스키마 생성 실패</td><td>사용자 정의 SchemaFilter 구현</td></tr><tr><td>순환 참조 오류</td><td>모델 간 순환 의존성</td><td>JsonIgnore 또는 DTO 패턴 적용</td></tr><tr><td>인증 테스트 실패</td><td>CORS 또는 인증 설정 문제</td><td>CORS 정책 및 인증 미들웨어 순서 확인</td></tr></tbody></table></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4c8.png" alt="📈" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 모니터링 및 분석</h2>



<h3 class="wp-block-heading">Application Insights 통합</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">builder.Services.AddApplicationInsightsTelemetry();

// Swagger 사용량 추적
app.UseSwagger(options =>
{
    options.PreSerializeFilters.Add((swagger, httpReq) =>
    {
        var telemetryClient = httpReq.HttpContext.RequestServices
            .GetRequiredService&lt;TelemetryClient>();
        telemetryClient.TrackEvent("SwaggerAccessed");
    });
});
</pre>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 요약 및 베스트 프랙티스</h2>



<h3 class="wp-block-heading">핵심 도구 정리</h3>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>도구/개념</th><th>설명</th><th>권장 사용 시나리오</th></tr></thead><tbody><tr><td><strong>OpenAPI/Swagger</strong></td><td>REST API 명세 표준</td><td>모든 REST API 프로젝트</td></tr><tr><td><strong>Swashbuckle.AspNetCore</strong></td><td>.NET용 Swagger 구현체</td><td>ASP.NET Core 웹 API</td></tr><tr><td><strong>Swagger UI</strong></td><td>인터랙티브 API 문서</td><td>개발 및 테스트 환경</td></tr><tr><td><strong>SwaggerGen</strong></td><td>코드 기반 문서 생성기</td><td>자동화된 문서 관리</td></tr></tbody></table></figure>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">개발팀을 위한 권장사항</h3>



<ol class="wp-block-list">
<li><strong>개발 초기</strong>부터 Swagger 도입하여 API 설계 단계에서 문서화</li>



<li><strong>XML 주석</strong>을 활용한 상세한 API 설명 작성</li>



<li><strong>DTO 패턴</strong> 적용으로 명확한 API 계약 정의</li>



<li><strong>버전 관리</strong> 전략 수립으로 하위 호환성 보장</li>



<li><strong>보안 설정</strong> 통합으로 실제 운영 환경과 일치하는 테스트 환경 구축</li>



<li><strong>CI/CD 파이프라인</strong>에 OpenAPI 스펙 검증 단계 포함</li>
</ol>



<p>이러한 접근을 통해 Swagger/OpenAPI는 단순한 문서화 도구를 넘어서 API 개발 생명주기 전반을 지원하는 핵심 인프라가 될 수 있습니다.</p>
<p>The post <a href="https://lycos7560.com/c/asp-net/swagger-openapi-for-net/40167/">Swagger/OpenAPI for .NET</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/c/asp-net/swagger-openapi-for-net/40167/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 2587번 (대표값2, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 07 Jul 2023 21:13:56 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[2587]]></category>
		<category><![CDATA[2587번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[대표값2]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2587]]></category>
		<category><![CDATA[백준 2587번]]></category>
		<category><![CDATA[사칙연산]]></category>
		<category><![CDATA[선택 정렬]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35752</guid>

					<description><![CDATA[<p>백준 2587번 '대표값2' 문제에 대한글입니다.  (This is an article about Baekjoon Number 2587 'Representative Value 2'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/">백준 2587번 (대표값2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-8b0bfb40      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#대표값2" class="uagb-toc-link__trigger">대표값2</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">대표값2</h1>



<p><a href="https://www.acmicpc.net/problem/2587" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/2587</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table><thead><tr><th>시간 제한</th><th>메모리 제한</th><th>제출</th><th>정답</th><th>맞힌 사람</th><th>정답 비율</th></tr></thead><tbody><tr><td>1 초</td><td>128 MB</td><td>31241</td><td>19249</td><td>17720</td><td>62.379%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>어떤 수들이 있을 때, 그 수들을 대표하는 값으로 가장 흔하게 쓰이는 것은 평균이다. </p>



<p>평균은 주어진 모든 수의 합을 수의 개수로 나눈 것이다. </p>



<p>예를 들어 10, 40, 30, 60, 30의 평균은 (10 + 40 + 30 + 60 + 30) / 5 = 170 / 5 = 34가 된다.</p>



<p>평균 이외의 또 다른 대표값으로 중앙값이라는 것이 있다. </p>



<p>중앙값은 주어진 수를 크기 순서대로 늘어 놓았을 때 가장 중앙에 놓인 값이다. </p>



<p>예를 들어 10, 40, 30, 60, 30의 경우, 크기 순서대로 늘어 놓으면</p>



<p>10 30 30 40 60</p>



<p>이 되고 따라서 중앙값은 30이 된다.</p>



<p>다섯 개의 자연수가 주어질 때 이들의 평균과 중앙값을 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄부터 다섯 번째 줄까지 한 줄에 하나씩 자연수가 주어진다. </p>



<p>주어지는 자연수는 100 보다 작은 10의 배수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에는 평균을 출력하고, 둘째 줄에는 중앙값을 출력한다. </p>



<p>평균과 중앙값은 모두 자연수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">10
40
30
60
30</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">34
30</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/2" target="_blank" rel="noreferrer noopener">Olympiad</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/55" target="_blank" rel="noreferrer noopener">한국정보올림피아드</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/57" target="_blank" rel="noreferrer noopener">한국정보올림피아드시․도지역본선</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/72" target="_blank" rel="noreferrer noopener">지역본선 2005</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/373" target="_blank" rel="noreferrer noopener">초등부</a>&nbsp;1번</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구</a><a href="https://www.acmicpc.net/problem/tag/102">현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/121" target="_blank" rel="noreferrer noopener">사칙연산</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>

using namespace std;

int _Arr[6], _Sum;

int main()
{
	for (int i = 0; i &lt; 5; i++)
		cin >> _Arr[i];
	// 배열의 크기가 작아서 선택 정렬을 사용
	for (int i = 0; i &lt; 5; i++)
		for (int j = 0; j &lt; 5; j++) {
			if (i == j) continue;
			if (_Arr[i] > _Arr[j]) {
				_Arr[5] = _Arr[i];
				_Arr[i] = _Arr[j];
				_Arr[j] = _Arr[5];
			}
		}
	for (int i = 0; i &lt; 5; i++)
		_Sum += _Arr[i];
	cout &lt;&lt; (int)(_Sum / 5) &lt;&lt; "\n";
	cout &lt;&lt; _Arr[2];

	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1205" height="99" src="https://lycos7560.com/wp-content/uploads/2023/07/image-15.png" alt="" class="wp-image-35755" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-15.png 1205w, https://lycos7560.com/wp-content/uploads/2023/07/image-15-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-15-768x63.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/">백준 2587번 (대표값2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 10867번 (중복 빼고 정렬하기, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10867%eb%b2%88-%ec%a4%91%eb%b3%b5-%eb%b9%bc%ea%b3%a0-%ec%a0%95%eb%a0%ac%ed%95%98%ea%b8%b0-c-baekjoon/35722/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10867%eb%b2%88-%ec%a4%91%eb%b3%b5-%eb%b9%bc%ea%b3%a0-%ec%a0%95%eb%a0%ac%ed%95%98%ea%b8%b0-c-baekjoon/35722/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 06 Jul 2023 05:32:30 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[10867]]></category>
		<category><![CDATA[10867번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 10867]]></category>
		<category><![CDATA[백준 10867번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[중복 빼고 정렬하기]]></category>
		<category><![CDATA[카운팅]]></category>
		<category><![CDATA[카운팅 정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35722</guid>

					<description><![CDATA[<p>백준 10867번 '중복 빼고 정렬하기' 문제에 대한 글입니다. 카운팅 정렬을 이용하여 해결하였습니다. (This article is about Baekjoon Number 10867 "Sorting Without Duplicate" problem. It was solved using counting alignment.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10867%eb%b2%88-%ec%a4%91%eb%b3%b5-%eb%b9%bc%ea%b3%a0-%ec%a0%95%eb%a0%ac%ed%95%98%ea%b8%b0-c-baekjoon/35722/">백준 10867번 (중복 빼고 정렬하기, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-c3a91233      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#중복-빼고-정렬하기" class="uagb-toc-link__trigger">중복 빼고 정렬하기</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">중복 빼고 정렬하기</h1>



<p><a href="https://www.acmicpc.net/problem/10867" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/10867</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">17763</td><td class="has-text-align-left" data-align="left">10164</td><td class="has-text-align-left" data-align="left">8622</td><td class="has-text-align-left" data-align="left">57.381%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>N개의 정수가 주어진다. </p>



<p>이때, N개의 정수를 오름차순으로 정렬하는 프로그램을 작성하시오. </p>



<p>같은 정수는 한 번만 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 수의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. </p>



<p>둘째에는 숫자가 주어진다. </p>



<p>이 수는 절댓값이 1,000보다 작거나 같은 정수이다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 수를 오름차순으로 정렬한 결과를 출력한다. </p>



<p>이때, 같은 수는 한 번만 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">10
1 4 2 3 1 4 2 3 1 2</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1 2 3 4</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 A</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">12
1 4 2 3 1 0 2 3 -1 -2 1000 -1000</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 A</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">-1000 -2 -1 0 1 2 3 4 1000</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/97">정렬</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>음수가 나올 수 있다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
using namespace std;
int _N;
bool _Arr[1001][2]; // 카운팅 정렬(Counting Sort, 계수 정렬)
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N;
	int _temp;
	for (int i = 0; i &lt; _N; i++) {
		cin >> _temp;
		if (_temp &lt; 0) _Arr[-_temp][1] = true;
		else _Arr[_temp][0] = true;
	}
	for (int i = 1000; i > 0; i--)
		if (_Arr[i][1])
			cout &lt;&lt; -i &lt;&lt; " ";
	for (int i = 0; i &lt;= 1000; i++)
		if (_Arr[i][0])
			cout &lt;&lt; i &lt;&lt; " ";
	return 0;
}
</pre>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1202" height="97" src="https://lycos7560.com/wp-content/uploads/2023/07/image-13.png" alt="" class="wp-image-35730" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-13.png 1202w, https://lycos7560.com/wp-content/uploads/2023/07/image-13-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-13-768x62.png 768w" sizes="(max-width: 1202px) 100vw, 1202px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10867%eb%b2%88-%ec%a4%91%eb%b3%b5-%eb%b9%bc%ea%b3%a0-%ec%a0%95%eb%a0%ac%ed%95%98%ea%b8%b0-c-baekjoon/35722/">백준 10867번 (중복 빼고 정렬하기, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10867%eb%b2%88-%ec%a4%91%eb%b3%b5-%eb%b9%bc%ea%b3%a0-%ec%a0%95%eb%a0%ac%ed%95%98%ea%b8%b0-c-baekjoon/35722/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 3273번 (두 수의 합, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-3273%eb%b2%88-%eb%91%90-%ec%88%98%ec%9d%98-%ed%95%a9-c-baekjoon/35663/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-3273%eb%b2%88-%eb%91%90-%ec%88%98%ec%9d%98-%ed%95%a9-c-baekjoon/35663/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 04 Jul 2023 13:58:38 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[3273]]></category>
		<category><![CDATA[3273번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[Two Pointer]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[두 수의 합]]></category>
		<category><![CDATA[두 포인터]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 3273]]></category>
		<category><![CDATA[백준 3273번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35663</guid>

					<description><![CDATA[<p>백준 3273번 '두 수의 합' 문제에 대한 글입니다. Two Pointer를 이용하여 문제를 해결하였습니다. (This article is about BaekJoon Number 3273 "sum of two numbers" problem. I solved the problem using Two Pointer.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-3273%eb%b2%88-%eb%91%90-%ec%88%98%ec%9d%98-%ed%95%a9-c-baekjoon/35663/">백준 3273번 (두 수의 합, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-d558e6fe      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#두-수의-합" class="uagb-toc-link__trigger">두 수의 합</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">두 수의 합</h1>



<p><a href="https://www.acmicpc.net/problem/3273" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/3273</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">39068</td><td class="has-text-align-left" data-align="left">13899</td><td class="has-text-align-left" data-align="left">10428</td><td class="has-text-align-left" data-align="left">34.896%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>n개의 서로 다른 양의 정수 a<sub>1</sub>, a<sub>2</sub>, &#8230;, a<sub>n</sub>으로 이루어진 수열이 있다. </p>



<p>a<sub>i</sub>의 값은 1보다 크거나 같고, 1000000보다 작거나 같은 자연수이다. </p>



<p>자연수 x가 주어졌을 때, a<sub>i</sub> + a<sub>j</sub> = x (1 ≤ i &lt; j ≤ n)을 만족하는 </p>



<p>(a<sub>i</sub>, a<sub>j</sub>)쌍의 수를 구하는 프로그램을 작성하시오.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 수열의 크기 n이 주어진다. </p>



<p>다음 줄에는 수열에 포함되는 수가 주어진다. </p>



<p>셋째 줄에는 x가 주어진다. </p>



<p>(1 ≤ n ≤ 100000, 1 ≤ x ≤ 2000000)</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>문제의 조건을 만족하는 쌍의 개수를 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1 1 1 6 0
2 7 8 3 1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">18</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/2" target="_blank" rel="noreferrer noopener">Olympiad</a> > <a href="https://www.acmicpc.net/category/94" target="_blank" rel="noreferrer noopener">Balkan Olympiad in Informatics</a> > <a href="https://www.acmicpc.net/category/273" target="_blank" rel="noreferrer noopener">Junior Balkan Olympiad in Informatics</a> > <a href="https://www.acmicpc.net/category/detail/1132" target="_blank" rel="noreferrer noopener">JBOI 2008</a> 6번</p>



<ul class="wp-block-list">
<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/BaaaaaaaaaaarkingDog">BaaaaaaaaaaarkingDog</a></li>



<li>문제를 번역한 사람: <a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/80" target="_blank" rel="noreferrer noopener">두 포인터</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Visual introduction Two Pointer Algorithm | Data Structure and Algorithm for Coding Interviews" width="1778" height="1000" src="https://www.youtube.com/embed/On03HWe2tZM?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
</div></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">통과된 코드</h2>



<p>투 포인터와 재귀를 이용하여 접근 </p>



<p>N이 1인 경우를 조심하자</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
#include &lt;algorithm>

using namespace std;

int _N, _Res = 0, _Sum;
vector&lt;int> _NumberV;

bool Greater(int a, int b)
{
	return a > b;
}

void TwoPointer(int _S, int _E)
{
	if (_S >= _E || _E >= _N || _S >= _N)
		return;
	if (_NumberV[_S] + _NumberV[_E] >= _Sum) {
		if (_NumberV[_S] + _NumberV[_E] == _Sum)
			_Res++;
		TwoPointer(_S + 1, _E);
	}
	else TwoPointer(_S, _E - 1);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N;
	int _Temp;
	for (int i = 0; i &lt; _N; i++) {
		cin >> _Temp;
		_NumberV.push_back(_Temp);
	}

	cin >> _Sum;
	sort(_NumberV.begin(), _NumberV.end(), Greater);
	if (_N > 1)
		TwoPointer(0, _N - 1);
	cout &lt;&lt; _Res;
	return 0;
}
</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1202" height="142" src="https://lycos7560.com/wp-content/uploads/2023/07/image-7.png" alt="" class="wp-image-35666" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-7.png 1202w, https://lycos7560.com/wp-content/uploads/2023/07/image-7-300x35.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-7-768x91.png 768w" sizes="(max-width: 1202px) 100vw, 1202px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>위는 백터를 이용(동적으로 생성) / 아래는 배열로 [100000]의 공간을 미리 선언</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-3273%eb%b2%88-%eb%91%90-%ec%88%98%ec%9d%98-%ed%95%a9-c-baekjoon/35663/">백준 3273번 (두 수의 합, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-3273%eb%b2%88-%eb%91%90-%ec%88%98%ec%9d%98-%ed%95%a9-c-baekjoon/35663/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1026번 (보물, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 03 Jul 2023 10:35:42 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1026]]></category>
		<category><![CDATA[1026번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그리디]]></category>
		<category><![CDATA[그리디 알고리즘]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1026]]></category>
		<category><![CDATA[백준 1026번]]></category>
		<category><![CDATA[보물]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35644</guid>

					<description><![CDATA[<p>백준 1026번 '보물' 문제에 대한 글입니다. (This article is about the issue of "Treasure" in Baekjoon Number 1026)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/">백준 1026번 (보물, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-bf784e4e      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#보물" class="uagb-toc-link__trigger">보물</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">보물</h1>



<p><a href="https://www.acmicpc.net/problem/1026" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1026</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">52186</td><td class="has-text-align-left" data-align="left">34340</td><td class="has-text-align-left" data-align="left">29166</td><td class="has-text-align-left" data-align="left">68.049%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>옛날 옛적에 수학이 항상 큰 골칫거리였던 나라가 있었다. </p>



<p>이 나라의 국왕 김지민은 다음과 같은 문제를 내고 큰 상금을 걸었다.</p>



<p>길이가 N인 정수 배열 A와 B가 있다. </p>



<p>다음과 같이 함수 S를 정의하자.</p>



<p>S = A[0] × B[0] + &#8230; + A[N-1] × B[N-1]</p>



<p>S의 값을 가장 작게 만들기 위해 A의 수를 재배열하자. </p>



<p>단, B에 있는 수는 재배열하면 안 된다.</p>



<p>S의 최솟값을 출력하는 프로그램을 작성하시오.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 N이 주어진다. </p>



<p>둘째 줄에는 A에 있는 N개의 수가 순서대로 주어지고, </p>



<p>셋째 줄에는 B에 있는 수가 순서대로 주어진다. </p>



<p>N은 50보다 작거나 같은 자연수이고, </p>



<p>A와 B의 각 원소는 100보다 작거나 같은 음이 아닌 정수이다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 S의 최솟값을 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1 1 1 6 0
2 7 8 3 1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">18</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
1 1 3
10 30 20</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">80</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">9
5 15 100 31 39 0 0 3 26
11 12 13 2 3 4 5 9 1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">528</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">힌트</h3>



<p>예제 1의 경우 A를 {1, 1, 0, 1, 6}과 같이 재배열하면 된다.</p>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/33" target="_blank" rel="noreferrer noopener">그리디 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/07/image-5.png" alt="" class="wp-image-35652" width="1076" height="752" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-5.png 1435w, https://lycos7560.com/wp-content/uploads/2023/07/image-5-300x210.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-5-768x537.png 768w" sizes="(max-width: 1076px) 100vw, 1076px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>문제에서 &#8220;단, B에 있는 수는 재배열하면 안 <em>된다.&#8221;라는</em> 문장이 왜 있는지 의문</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>
using namespace std;
int _N, _Res = 0, _A[50], _B[50];
// 오름차순 정렬
bool Greater(int a, int b)
{
	return a > b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N;
	for (int i = 0; i &lt; _N; i++)
		cin >> _A[i];
	for (int i = 0; i &lt; _N; i++)
		cin >> _B[i];
	sort(_A, _A + _N, Greater);
	sort(_B, _B + _N);
	for (int i = 0; i &lt; _N; i++)
		_Res += (_B[i] * _A[i]);
	cout &lt;&lt; _Res;
	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1205" height="96" src="https://lycos7560.com/wp-content/uploads/2023/07/image-6.png" alt="" class="wp-image-35653" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-6.png 1205w, https://lycos7560.com/wp-content/uploads/2023/07/image-6-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-6-768x61.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/">백준 1026번 (보물, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 25305번 (커트라인, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-25305%eb%b2%88-%ec%bb%a4%ed%8a%b8%eb%9d%bc%ec%9d%b8-c-baekjoon/35539/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-25305%eb%b2%88-%ec%bb%a4%ed%8a%b8%eb%9d%bc%ec%9d%b8-c-baekjoon/35539/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 23 Jun 2023 05:11:20 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[25305]]></category>
		<category><![CDATA[25305번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 25305]]></category>
		<category><![CDATA[백준 25305번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[커트라인]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35539</guid>

					<description><![CDATA[<p>백준 25305번 '커트라인' 문제에 대한 글입니다. 정렬을 이용한 단순 구현 문제입니다. (This is an article about Baekjoon Number 25305 'cut line' problem. Simple implementation problem using alignment.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-25305%eb%b2%88-%ec%bb%a4%ed%8a%b8%eb%9d%bc%ec%9d%b8-c-baekjoon/35539/">백준 25305번 (커트라인, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-6326893d      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#커트라인" class="uagb-toc-link__trigger">커트라인</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">커트라인</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/25305" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/25305</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">1024 MB</td><td class="has-text-align-left" data-align="left">22308</td><td class="has-text-align-left" data-align="left">14510</td><td class="has-text-align-left" data-align="left">13398</td><td class="has-text-align-left" data-align="left">66.202%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>2022 연세대학교 미래캠퍼스 슬기로운 코딩생활에 N명의 학생들이 응시했다.</p>



<p>이들 중 점수가 가장 높은 k명은 상을 받을 것이다. 이 때, 상을 받는 커트라인이 몇 점인지 구하라.</p>



<p>커트라인이란 상을 받는 사람들&nbsp;중 점수가 가장 가장 낮은 사람의 점수를 말한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에는 응시자의 수 N과 상을 받는 사람의 수 k가 공백을 사이에 두고 주어진다.</p>



<p>둘째 줄에는 각 학생의 점수 x가 공백을 사이에 두고 주어진다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>상을 받는&nbsp;커트라인을 출력하라.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">제한</h3>



<ul class="wp-block-list">
<li> 1 ≤ N ≤ 1,000 </li>



<li>1 ≤ k ≤ N </li>



<li> 0 ≤ x ≤ 10,000 </li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 2
100 76 85 93 98</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">98</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>시험 응시자들 가운데 1등은 100점, 2등은 98점, 3등은 93점이다. </p>



<p>2등까지 상을 받으므로 커트라인은 98점이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출처</h3>



<p><a href="https://www.acmicpc.net/category/5" target="_blank" rel="noreferrer noopener">University</a> > <a href="https://www.acmicpc.net/category/541" target="_blank" rel="noreferrer noopener">연세대학교 미래캠퍼스</a> > <a href="https://www.acmicpc.net/category/detail/3136" target="_blank" rel="noreferrer noopener">2022 연세대학교 미래캠퍼스 슬기로운 코딩생활</a> B번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람: <a href="https://www.acmicpc.net/user/jhnah917" target="_blank" rel="noreferrer noopener">jhnah917</a>, <a href="https://www.acmicpc.net/user/yclock" target="_blank" rel="noreferrer noopener">yclock</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/junie" target="_blank" rel="noreferrer noopener">junie</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading">통과된 코드</h2>



<p>오름차순으로 정렬 후 상을 받는 커트라인 점수를 출력 </p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>
using namespace std;
int _N, _K, _ScoreArr[1000];

// 오름차순 정렬
bool Greater(int a, int b) 
{
	return a > b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N >> _K;
	for (int i = 0; i &lt; _N; i++)
		cin >> _ScoreArr[i];
	sort(_ScoreArr, _ScoreArr + _N, Greater);
	cout &lt;&lt; _ScoreArr[_K-1]; // 커트라인
	return 0;
} </pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1206" height="100" src="https://lycos7560.com/wp-content/uploads/2023/06/image-37.png" alt="" class="wp-image-35546" srcset="https://lycos7560.com/wp-content/uploads/2023/06/image-37.png 1206w, https://lycos7560.com/wp-content/uploads/2023/06/image-37-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/06/image-37-768x64.png 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-25305%eb%b2%88-%ec%bb%a4%ed%8a%b8%eb%9d%bc%ec%9d%b8-c-baekjoon/35539/">백준 25305번 (커트라인, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-25305%eb%b2%88-%ec%bb%a4%ed%8a%b8%eb%9d%bc%ec%9d%b8-c-baekjoon/35539/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1141번 (접두사, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1141%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-c-baekjoon/34016/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1141%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-c-baekjoon/34016/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sat, 11 Mar 2023 18:56:40 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1141]]></category>
		<category><![CDATA[1141번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[Trie]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[문자열]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1141]]></category>
		<category><![CDATA[백준 1141번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[자료 구조]]></category>
		<category><![CDATA[자료구조]]></category>
		<category><![CDATA[접두사]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[트라이]]></category>
		<category><![CDATA[트라이(Trie)]]></category>
		<category><![CDATA[트리]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=34016</guid>

					<description><![CDATA[<p>백준 1141번 '접두사' 문제에 대한 글입니다. 'Trie' 자료구조를 이용하여 해결하였습니다. (This is an article about the 'prefix' problem in Baekjoon 1141. We solved it using the 'Trie' data structure.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1141%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-c-baekjoon/34016/">백준 1141번 (접두사, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-9d3b3ff9      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#접두사" class="uagb-toc-link__trigger">접두사</a><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">접두사</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/1141">https://www.acmicpc.net/problem/1141</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure id="problem-info" class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">2191</td><td class="has-text-align-left" data-align="left">1055</td><td class="has-text-align-left" data-align="left">877</td><td class="has-text-align-left" data-align="left">50.460%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문제</h2>



<p class="has-medium-font-size">접두사X 집합이란 집합의 어떤 한 단어가, 다른 단어의 접두어가 되지 않는 집합이다. </p>



<p class="has-medium-font-size">예를 들어, {hello}, {hello, goodbye, giant, hi}, 비어있는 집합은 모두 접두사X 집합이다. </p>



<p class="has-medium-font-size">하지만, {hello, hell}, {giant, gig, g}는 접두사X 집합이 아니다.</p>



<p class="has-medium-font-size">단어 N개로 이루어진 집합이 주어질 때, 접두사X 집합인 부분집합의 최대 크기를 출력하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">입력</h2>



<p class="has-medium-font-size">첫째 줄에 단어의 개수 N이 주어진다. N은 50보다 작거나 같은 자연수이다. </p>



<p class="has-medium-font-size">둘째 줄부터 N개의 줄에는 단어가 주어진다. </p>



<p class="has-medium-font-size">단어는 알파벳 소문자로만 이루어져 있고, 길이는 최대 50이다. </p>



<p class="has-medium-font-size">집합에는 같은 단어가 두 번 이상 있을 수 있다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출력</h2>



<p class="has-medium-font-size">첫째 줄에 문제의 정답을 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6
hello
hi
h
run
rerun
running</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">4</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 2</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6
a
b
cba
cbc
cbb
ccc</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 2</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 3</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6
a
ab
abc
abcd
abcde
abcdef</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 3</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 4</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
topcoder
topcoder
topcoding</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 4</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출처</h2>



<ul class="wp-block-list">
<li>문제를 번역한 사람: <a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/158" target="_blank" rel="noreferrer noopener">문자열</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/120" target="_blank" rel="noreferrer noopener">트리</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/79" target="_blank" rel="noreferrer noopener">트라이</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h1 class="wp-block-heading">통과된 코드</h1>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;set>
#include &lt;unordered_map>

using namespace std;

// TrieNode클래스를 사용하여 Trie의 각 노드를 표현
class TrieNode {

public:
    unordered_map&lt;char, TrieNode*> children;
    bool isEndOfWord;

    TrieNode() {
        isEndOfWord = false;
    }

};

// Trie 클래스
class Trie {

    // Trie의 루트 노드에 대한 포인터인 Trie개인 멤버 변수
private:
    TrieNode* root; // 루트 노드

// 생성자새 인스턴스를 만들고 Trie를 초기화합
public:
    Trie() {
        root = new TrieNode();
    }

    // 문자열을 받아 Trie에 추가합니다. 
    // 루트 노드에서 시작하여 Trie 아래로 이동하여 단어의 각 문자에 필요한 새 노드를 만듭니다.
    void insert(string word) {
        TrieNode* curr = root; // 시작
        for (char c : word) {
            if (curr->children.find(c) == curr->children.end()) 
                curr->children[c] = new TrieNode(); // Trie에 없다면 새 노드 생성
            
            curr = curr->children[c]; // Trie에 이미 존재하는 경우 기존 노드로 이동
        }
        // 단어의 끝을 나타내는 isEndOfWord bool값
        curr->isEndOfWord = true;
    }

    // prefix(접두사)로 시작하는 단어가 Trie에 있는지 확인
    int startsWith(string prefix) {
        TrieNode* curr = root;
        for (char c : prefix) {
            if (curr->children.find(c) == curr->children.end()) 
                return curr->children.size();
            
            curr = curr->children[c];
        }
        return curr->children.size();
    }
};

int main() {

    Trie trie;
    int N;
    set&lt;string> myV;
    string str;

    cin >> N;

    for (int i = 0; i &lt; N; i++) {
        cin >> str;
        myV.insert(str); // set으로 중복 제거
        trie.insert(str);
    }

    int res = myV.size();

    for (auto &amp;it : myV) 
        if (trie.startsWith(it) >= 1 ) res--;
    
    cout &lt;&lt; res;

    return 0;
}
</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/03/image-56.png" alt="" class="wp-image-34018" width="1088" height="98" srcset="https://lycos7560.com/wp-content/uploads/2023/03/image-56.png 1036w, https://lycos7560.com/wp-content/uploads/2023/03/image-56-300x27.png 300w, https://lycos7560.com/wp-content/uploads/2023/03/image-56-768x69.png 768w" sizes="(max-width: 1088px) 100vw, 1088px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1141%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-c-baekjoon/34016/">백준 1141번 (접두사, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1141%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-c-baekjoon/34016/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 14426번 (접두사 찾기, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14426%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-%ec%b0%be%ea%b8%b0-c-baekjoon/34046/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14426%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-%ec%b0%be%ea%b8%b0-c-baekjoon/34046/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sat, 11 Mar 2023 00:09:48 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[14426]]></category>
		<category><![CDATA[14426번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[Trie]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[문자열]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 14426]]></category>
		<category><![CDATA[백준 14426번]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[자료 구조]]></category>
		<category><![CDATA[자료구조]]></category>
		<category><![CDATA[접두사]]></category>
		<category><![CDATA[접두사 찾기]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[트라이]]></category>
		<category><![CDATA[트라이(Trie)]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=34046</guid>

					<description><![CDATA[<p>백준 14426번 '접두사 찾기' 문제에 대한 글입니다. '트라이' 자료구조를 이용하여 해결하였습니다. (This is an article on the 'find prefix' problem in Baekjun 14426. We solved it using the 'Trie' data structure.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14426%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-%ec%b0%be%ea%b8%b0-c-baekjoon/34046/">백준 14426번 (접두사 찾기, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-2709ce82      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#접두사-찾기" class="uagb-toc-link__trigger">접두사 찾기</a><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">접두사 찾기</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/14426" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/14426</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure id="problem-info" class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">1536 MB</td><td class="has-text-align-left" data-align="left">2587</td><td class="has-text-align-left" data-align="left">781</td><td class="has-text-align-left" data-align="left">574</td><td class="has-text-align-left" data-align="left">49.228%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문제</h2>



<p class="has-medium-font-size">문자열 S의 접두사란 S의 가장 앞에서부터 부분 문자열을 의미한다. </p>



<p class="has-medium-font-size">예를 들어, S = &#8220;codeplus&#8221;의 접두사는 &#8220;code&#8221;, &#8220;co&#8221;, &#8220;codepl&#8221;, &#8220;codeplus&#8221;가 있고, &#8220;plus&#8221;, &#8220;s&#8221;, &#8220;cude&#8221;, &#8220;crud&#8221;는 접두사가 아니다.</p>



<p class="has-medium-font-size">총 N개의 문자열로 이루어진 집합 S가 주어진다.</p>



<p class="has-medium-font-size">입력으로 주어지는 M개의 문자열 중에서 집합 S에 포함되어 있는 문자열 중 </p>



<p class="has-medium-font-size">적어도 하나의 접두사인 것의 개수를 구하는 프로그램을 작성하시오.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">입력</h2>



<p class="has-medium-font-size">첫째 줄에 문자열의 개수 N과 M (1 ≤ N ≤ 10,000, 1 ≤ M ≤ 10,000)이 주어진다.</p>



<p class="has-medium-font-size">다음 N개의 줄에는 집합 S에 포함되어 있는 문자열이 주어진다.</p>



<p class="has-medium-font-size">다음 M개의 줄에는 검사해야 하는 문자열이 주어진다.</p>



<p class="has-medium-font-size">입력으로 주어지는 문자열은 알파벳 소문자로만 이루어져 있으며, 길이는 500을 넘지 않는다. </p>



<p class="has-medium-font-size">집합 S에 같은 문자열이 여러 번 주어지는 경우는 없다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출력</h2>



<p class="has-medium-font-size">첫째 줄에 M개의 문자열 중에 총 몇 개가 포함되어 있는 문자열 중 적어도 하나의 접두사인지 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5 10
baekjoononlinejudge
startlink
codeplus
sundaycoding
codingsh
baekjoon
star
start
code
sunday
coding
cod
online
judge
plus</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">7</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출처</h2>



<ul class="wp-block-list">
<li>문제를 만든 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/besyia0k0" target="_blank" rel="noreferrer noopener">besyia0k0</a>,&nbsp;<a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a></li>



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/Green55" target="_blank" rel="noreferrer noopener">Green55</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/158" target="_blank" rel="noreferrer noopener">문자열</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/120" target="_blank" rel="noreferrer noopener">트리</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/79" target="_blank" rel="noreferrer noopener">트라이</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h1 class="wp-block-heading">통과된 코드</h1>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;unordered_map>

using namespace std;

// TrieNode클래스를 사용하여 Trie의 각 노드를 표현
class TrieNode {

public:
    unordered_map&lt;char, TrieNode*> children;
};

// Trie 클래스
class Trie {

    // Trie의 루트 노드에 대한 포인터인 Trie개인 멤버 변수
private:
    TrieNode* root; // 루트 노드

// 생성자새 인스턴스를 만들고 Trie를 초기화합
public:
    Trie() {
        root = new TrieNode();
    }

    // 문자열을 받아 Trie에 추가합니다. 
    // 루트 노드에서 시작하여 Trie 아래로 이동하여 단어의 각 문자에 필요한 새 노드를 만듭니다.
    void insert(string word) {
        TrieNode* curr = root; // 시작
        for (char c : word) {
            if (curr->children.find(c) == curr->children.end())
                curr->children[c] = new TrieNode(); // Trie에 없다면 새 노드 생성

            curr = curr->children[c]; // Trie에 이미 존재하는 경우 기존 노드로 이동
        }
    }

    // prefix(접두사)로 시작하는 단어가 Trie에 있는지 확인
    bool startsWith(string prefix) {
        TrieNode* curr = root;
        for (char c : prefix) {
            if (curr->children.find(c) == curr->children.end()) {
                return false;
            }
            curr = curr->children[c];
        }
        return true;
    }
};

int main() {

    ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
    // cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
    cin.tie(NULL);
    cout.tie(NULL);

    Trie trie;
    int N, M, res = 0;
    string str;

    cin >> N >> M;

    for (int i = 0; i &lt; N; i++) {
        cin >> str;
        trie.insert(str); // 트라이 입력
    }

    for (int i = 0; i &lt; M; i++) {
        cin >> str;
        if (trie.startsWith(str)) res++; // 접두사 확인
    }

    cout &lt;&lt; res;

    return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="906" height="95" src="https://lycos7560.com/wp-content/uploads/2023/03/image-57.png" alt="" class="wp-image-34049" srcset="https://lycos7560.com/wp-content/uploads/2023/03/image-57.png 906w, https://lycos7560.com/wp-content/uploads/2023/03/image-57-300x31.png 300w, https://lycos7560.com/wp-content/uploads/2023/03/image-57-768x81.png 768w" sizes="(max-width: 906px) 100vw, 906px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14426%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-%ec%b0%be%ea%b8%b0-c-baekjoon/34046/">백준 14426번 (접두사 찾기, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-14426%eb%b2%88-%ec%a0%91%eb%91%90%ec%82%ac-%ec%b0%be%ea%b8%b0-c-baekjoon/34046/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 18110번 (solved.ac, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18110%eb%b2%88-solved-ac-c-baekjoon/35885/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18110%eb%b2%88-solved-ac-c-baekjoon/35885/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Sun, 12 Feb 2023 01:13:34 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[11000번]]></category>
		<category><![CDATA[18110]]></category>
		<category><![CDATA[18110번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cmath]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[solved.ac]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[반올림]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 18110]]></category>
		<category><![CDATA[백준 18110번]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35885</guid>

					<description><![CDATA[<p>백준 18110번 'solved.ac' 문제에 대한 글입니다. 단순한 구현 문제 입니다. (This article is about the question of Baekjoon Number 18110 'solved.ac '. It's a simple implementation problem.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18110%eb%b2%88-solved-ac-c-baekjoon/35885/">백준 18110번 (solved.ac, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-ab1cded6      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#solvedac" class="uagb-toc-link__trigger">solved.ac</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">solved.ac</h1>



<p><a href="https://www.acmicpc.net/problem/18110" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/18110</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초 (추가 시간 없음)</td><td class="has-text-align-left" data-align="left">1024 MB</td><td class="has-text-align-left" data-align="left">8645</td><td class="has-text-align-left" data-align="left">2335</td><td class="has-text-align-left" data-align="left">2010</td><td class="has-text-align-left" data-align="left">27.328%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p><a href="http://solved.ac/" target="_blank" rel="noreferrer noopener">solved.ac</a>는 Sogang ICPC Team 학회원들의 알고리즘 공부에 도움을 주고자 만든 서비스이다. </p>



<p>지금은 서강대뿐만 아니라 수많은 사람들이 solved.ac의 도움을 받아 알고리즘 공부를 하고 있다.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="523" height="134" src="https://lycos7560.com/wp-content/uploads/2023/07/image-22.png" alt="" class="wp-image-35886" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-22.png 523w, https://lycos7560.com/wp-content/uploads/2023/07/image-22-300x77.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p>ICPC Team은 백준 온라인 저지에서 문제풀이를 연습하는데, 백준 온라인 저지의 문제들에는 난이도 표기가 없어서, </p>



<p>지금까지는 다양한 문제를 풀어 보고 싶더라도 난이도를 가늠하기 어려워 무슨 문제를 풀어야 할지 판단하기 곤란했기 때문에 solved.ac가 만들어졌다. </p>



<p>solved.ac가 생긴 이후 전국에서 200명 이상의 기여자 분들께서 소중한 난이도 의견을 공유해 주셨고, 지금은 약 7,000문제에 난이도 표기가 붙게 되었다.</p>



<p>어떤 문제의 난이도는 그 문제를 푼 사람들이 제출한 <strong>난이도 의견</strong>을 바탕으로 결정한다. </p>



<p>난이도 의견은 그 사용자가 생각한 난이도를 의미하는 정수 하나로 주어진다. solved.ac가 사용자들의 의견을 바탕으로 난이도를 결정하는 방식은 다음과 같다.</p>



<ul class="wp-block-list">
<li>아직 아무 의견이 없다면 문제의 난이도는 0으로 결정한다.</li>



<li>의견이 하나 이상 있다면, 문제의 난이도는 모든 사람의 난이도 의견의 30% 절사평균으로 결정한다.</li>
</ul>



<p>절사평균이란 극단적인 값들이 평균을 왜곡하는 것을 막기 위해 가장 큰 값들과 가장 작은 값들을 제외하고 평균을 내는 것을 말한다. </p>



<p>30% 절사평균의 경우 위에서 15%, 아래에서 15%를 각각 제외하고 평균을 계산한다. </p>



<p>따라서 20명이 투표했다면, 가장 높은 난이도에 투표한 3명과 가장 낮은 난이도에 투표한 3명의 투표는 평균 계산에 반영하지 않는다는 것이다.</p>



<p>제외되는 사람의 수는 위, 아래에서 각각 반올림한다. </p>



<p>25명이 투표한 경우 위, 아래에서 각각 3.75명을 제외해야 하는데, 이 경우 반올림해 4명씩을 제외한다.</p>



<p>마지막으로, 계산된 평균도 정수로 반올림된다. </p>



<p>절사평균이 16.7이었다면 최종 난이도는 17이 된다.</p>



<p>사용자들이 어떤 문제에 제출한 난이도 의견 목록이 주어질 때, solved.ac가 결정한 문제의 난이도를 계산하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫 번째 줄에 난이도 의견의 개수&nbsp;<em>n</em>이 주어진다. (0&nbsp;≤&nbsp;<em>n</em>&nbsp;≤ 3 × 10<sup>5</sup>)</p>



<p>이후 두 번째 줄부터 1 +&nbsp;<em>n</em>번째 줄까지 사용자들이 제출한 난이도 의견&nbsp;<em>n</em>개가 한 줄에 하나씩 주어진다. 모든 난이도 의견은 1 이상 30 이하이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>solved.ac가 계산한 문제의 난이도를 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1
5
5
7
8</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>5명의 15%는 0.75명으로, 이를 반올림하면 1명이다. </p>



<p>따라서 solved.ac는 가장 높은 난이도 의견과 가장 낮은 난이도 의견을 하나씩 제외하고, {5, 5, 7}에 대한 평균으로 문제 난이도를 결정한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">10
1
13
12
15
3
16
13
12
14
15</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">13</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/5" target="_blank" rel="noreferrer noopener">University</a> > <a href="https://www.acmicpc.net/category/83" target="_blank" rel="noreferrer noopener">서강대학교</a> > <a href="https://www.acmicpc.net/category/693" target="_blank" rel="noreferrer noopener">2019 Sogang Programming Contest</a> > <a href="https://www.acmicpc.net/category/detail/2128" target="_blank" rel="noreferrer noopener">Champion</a> A번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람: <a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a>, <a href="https://www.acmicpc.net/user/kipa00" target="_blank" rel="noreferrer noopener">kipa00</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/sait2000" target="_blank" rel="noreferrer noopener">sait2000</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/shiftpsh" target="_blank" rel="noreferrer noopener">shiftpsh</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>단순 수학을 이용한 구현 문제입니다.</p>



<p>N = 0 일 경우를 꼭 처리해줘야 합니다. (0을 나누면 큰일납니다.)</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>
#include &lt;cmath>
using namespace std;
int _N, _Sum, _Arr[300000];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N;
	for (int i = 0; i &lt; _N; i++)
		cin >> _Arr[i];
	sort(_Arr, _Arr + _N);
	int _Temp = round((float)_N * 0.15f);
	for (int i = _Temp; i &lt; _N - _Temp; i++)
		_Sum += _Arr[i];
	if (_N == 0) cout &lt;&lt; "0";
	else cout &lt;&lt; round((float)_Sum / (float)(_N - 2 * _Temp));
	return 0;
}</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1066" height="124" src="https://lycos7560.com/wp-content/uploads/2023/07/image-23.png" alt="" class="wp-image-35900" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-23.png 1066w, https://lycos7560.com/wp-content/uploads/2023/07/image-23-300x35.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-23-768x89.png 768w" sizes="(max-width: 1066px) 100vw, 1066px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18110%eb%b2%88-solved-ac-c-baekjoon/35885/">백준 18110번 (solved.ac, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-18110%eb%b2%88-solved-ac-c-baekjoon/35885/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 10815번 (숫자 카드, C++, Binary Search) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10815%eb%b2%88-%ec%88%ab%ec%9e%90-%ec%b9%b4%eb%93%9c-c-binary-search-baekjoon/5862/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10815%eb%b2%88-%ec%88%ab%ec%9e%90-%ec%b9%b4%eb%93%9c-c-binary-search-baekjoon/5862/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 31 Jan 2023 13:12:25 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[10815]]></category>
		<category><![CDATA[10815번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Binary Search]]></category>
		<category><![CDATA[BinarySearch]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 10815]]></category>
		<category><![CDATA[백준 10815번]]></category>
		<category><![CDATA[숫자 카드]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[이분탐색]]></category>
		<category><![CDATA[이진탐색]]></category>
		<category><![CDATA[자료구조]]></category>
		<category><![CDATA[재귀]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<category><![CDATA[함수]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=5862</guid>

					<description><![CDATA[<p>백준(BAEKJOON) 10815번 '숫자 카드' 문제에 대한 글입니다. 'Binary Search' 를 이용하여 해결하였습니다. (This is an article about the 'number card' problem in BAEKJOON 10815. I solved it using 'Binary Search'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10815%eb%b2%88-%ec%88%ab%ec%9e%90-%ec%b9%b4%eb%93%9c-c-binary-search-baekjoon/5862/">백준 10815번 (숫자 카드, C++, Binary Search) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">숫자 카드</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/10815" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/10815</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure id="problem-info" class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">70735</td><td class="has-text-align-left" data-align="left">32252</td><td class="has-text-align-left" data-align="left">23137</td><td class="has-text-align-left" data-align="left">44.720%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문제</h2>



<p class="has-medium-font-size">숫자 카드는 정수 하나가 적혀져 있는 카드이다. </p>



<p class="has-medium-font-size">상근이는 숫자 카드 N개를 가지고 있다.&nbsp;</p>



<p class="has-medium-font-size">정수 M개가 주어졌을 때, </p>



<p class="has-medium-font-size">이 수가 적혀있는 숫자 카드를 상근이가 가지고 있는지 아닌지를 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">입력</h2>



<p class="has-medium-font-size">첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. </p>



<p class="has-medium-font-size">둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. </p>



<p class="has-medium-font-size">숫자 카드에 적혀있는 수는&nbsp;-10,000,000보다 크거나 같고, 10,000,000보다 작거나 같다. </p>



<p class="has-medium-font-size">두 숫자&nbsp;카드에 같은 수가 적혀있는 경우는 없다.</p>



<p class="has-medium-font-size">셋째 줄에는 M(1 ≤ M ≤ 500,000)이 주어진다. </p>



<p class="has-medium-font-size">넷째 줄에는 상근이가 가지고 있는 숫자 카드인지 아닌지를 구해야 할 M개의 정수가 주어지며, </p>



<p class="has-medium-font-size">이 수는 공백으로 구분되어져 있다. 이 수도&nbsp;-10,000,000보다 크거나 같고, 10,000,000보다 작거나 같다</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출력</h2>



<p class="has-medium-font-size">첫째 줄에 입력으로 주어진 M개의 수에 대해서, </p>



<p class="has-medium-font-size">각&nbsp;수가 적힌 숫자 카드를&nbsp;상근이가 가지고 있으면 1을, 아니면 0을 공백으로 구분해 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 입력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
6 3 2 10 -10
8
10 9 -5 2 3 4 5 -10</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">예제 출력 1</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1 0 0 1 1 0 0 1</pre>



<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출처</h2>



<ul class="wp-block-list">
<li>문제를 만든 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/cko301" target="_blank" rel="noreferrer noopener">cko301</a>,&nbsp;<a href="https://www.acmicpc.net/user/eric00513" target="_blank" rel="noreferrer noopener">eric00513</a>,&nbsp;<a href="https://www.acmicpc.net/user/lety" target="_blank" rel="noreferrer noopener">lety</a>,&nbsp;<a href="https://www.acmicpc.net/user/mystika" target="_blank" rel="noreferrer noopener">mystika</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/175" target="_blank" rel="noreferrer noopener">자료 구조</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/12" target="_blank" rel="noreferrer noopener">이분 탐색</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/01/image-53.png" alt="" class="wp-image-5867" width="626" height="463" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-53.png 820w, https://lycos7560.com/wp-content/uploads/2023/01/image-53-300x222.png 300w, https://lycos7560.com/wp-content/uploads/2023/01/image-53-768x568.png 768w" sizes="(max-width: 626px) 100vw, 626px" /></figure>



<div style="height:43px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="has-medium-font-size">순회 형식으로 구현하면 숫자 하나를 확인할때 마다 500,000번의 연산이 필요하다. (시간 초과)</p>



<p class="has-medium-font-size">순회로 확인하는 방법보다 더 빠른 탐색 방법이 필요한데 </p>



<p class="has-medium-font-size">이럴 때 binary search를 이용하여 탐색의 시간 복잡도를 O(logN)으로 만들 수 있다.</p>



<p class="has-medium-font-size">코드는 재귀적으로 작성하였고 해설 참고하면 쉽게 이해가 가능하다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>

using namespace std;

constexpr int MAX = 500000;

int arr[MAX];

int N , M, target;

// 이분 탐색 함수
bool BinarySearch(int tArr[MAX], int start, int end, int target)
{
	if (start > end) return false; // 만족하는 결과가 없다 false return

	int mid = (start + end) / 2; // 중간 값을 찾아준다.

	if (arr[mid] == target)	return true; // 만족하는 결과!! true return

	// 찾는 수가 더 작다면, 검사 범위를 더 작게해서 다시 이분탐색 // 결과가 나오면 return
	// 찾는 수가 더 크면, 검사 범위를 더 크게해서 다시 이분탐색 // 결과가 나오면 return
	if (arr[mid] > target) return BinarySearch(arr, start, mid - 1, target);
	else return BinarySearch(arr, mid + 1, end, target);
}

int main()
{
	ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
	// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> N;

	for (int i = 0; i &lt; N; i++) cin >> arr[i];
	
	// 이분 탐색을 위한 오름차순 정렬을 수행한다.
	sort(arr, arr + N);

	// 탐색할 숫자의 개수를 입력받는다.
	cin >> M;

	for (int i = 0; i &lt; M; i++) {
		
		cin >> target;
		
		// 이진 탐색 후 출력
		cout &lt;&lt; BinarySearch(arr, 0, N - 1, target) &lt;&lt; "\n";

	}

	return 0;
}</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1037" height="99" src="https://lycos7560.com/wp-content/uploads/2023/01/image-52.png" alt="" class="wp-image-5863" srcset="https://lycos7560.com/wp-content/uploads/2023/01/image-52.png 1037w, https://lycos7560.com/wp-content/uploads/2023/01/image-52-300x29.png 300w, https://lycos7560.com/wp-content/uploads/2023/01/image-52-768x73.png 768w" sizes="(max-width: 1037px) 100vw, 1037px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10815%eb%b2%88-%ec%88%ab%ec%9e%90-%ec%b9%b4%eb%93%9c-c-binary-search-baekjoon/5862/">백준 10815번 (숫자 카드, C++, Binary Search) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-10815%eb%b2%88-%ec%88%ab%ec%9e%90-%ec%b9%b4%eb%93%9c-c-binary-search-baekjoon/5862/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
