-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Silver III] Title: 블로그, Time: 300 ms, Memory: 60100 KB -BaekjoonHub
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# [Silver III] 블로그 - 21921 | ||
|
||
[문제 링크](https://www.acmicpc.net/problem/21921) | ||
|
||
### 성능 요약 | ||
|
||
메모리: 60100 KB, 시간: 300 ms | ||
|
||
### 분류 | ||
|
||
누적 합, 슬라이딩 윈도우 | ||
|
||
### 제출 일자 | ||
|
||
2024년 5월 26일 18:25:07 | ||
|
||
### 문제 설명 | ||
|
||
<p>찬솔이는 블로그를 시작한 지 벌써 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>일이 지났다.</p> | ||
|
||
<p>요즘 바빠서 관리를 못 했다가 방문 기록을 봤더니 벌써 누적 방문 수가 6만을 넘었다.</p> | ||
|
||
<p style="text-align: center;"><img alt="" src="https://upload.acmicpc.net/5f95a11c-b879-408b-b3be-dcaa915f36ab/-/preview/" style="height: 295px; width: 600px;"></p> | ||
|
||
<p>찬솔이는 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D44B TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$X$</span></mjx-container>일 동안 가장 많이 들어온 방문자 수와 그 기간들을 알고 싶다.</p> | ||
|
||
<p>찬솔이를 대신해서 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D44B TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$X$</span></mjx-container>일 동안 가장 많이 들어온 방문자 수와 기간이 몇 개 있는지 구해주자.</p> | ||
|
||
### 입력 | ||
|
||
<p>첫째 줄에 블로그를 시작하고 지난 일수 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>와 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D44B TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$X$</span></mjx-container>가 공백으로 구분되어 주어진다.</p> | ||
|
||
<p>둘째 줄에는 블로그 시작 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c31"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>1</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$1$</span></mjx-container>일차부터 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D441 TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>N</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$N$</span></mjx-container>일차까지 하루 방문자 수가 공백으로 구분되어 주어진다.</p> | ||
|
||
### 출력 | ||
|
||
<p>첫째 줄에 <mjx-container class="MathJax" jax="CHTML" style="font-size: 109%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mi class="mjx-i"><mjx-c class="mjx-c1D44B TEX-I"></mjx-c></mjx-mi></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>X</mi></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$X$</span></mjx-container>일 동안 가장 많이 들어온 방문자 수를 출력한다. 만약 최대 방문자 수가 0명이라면 <strong>SAD</strong>를 출력한다.</p> | ||
|
||
<p>만약 최대 방문자 수가 0명이 아닌 경우 둘째 줄에 기간이 몇 개 있는지 출력한다.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import sys | ||
from collections import deque | ||
|
||
|
||
# sys.setrecursionlimit(100000) | ||
|
||
def input(): | ||
return sys.stdin.readline() | ||
|
||
|
||
# main | ||
if __name__ == "__main__": | ||
N, X = map(int, input().split()) | ||
tmp = list(map(int, input().split())) | ||
lst = [0] * N | ||
lst[0] = tmp[0] | ||
for i in range(1, N): | ||
lst[i] = lst[i - 1] + tmp[i] | ||
visited_max = 0 | ||
cnt = 1 | ||
for i in range(X - 1, N): # 5, 2 -> (0~1) (1~2) (2~3) (3~4) / 7, 5 -> (0, 4) (1, 5) (2, 6) | ||
if i - X != -1: | ||
if visited_max == lst[i] - lst[i - X]: | ||
cnt += 1 | ||
elif visited_max < lst[i] - lst[i - X]: | ||
cnt = 1 | ||
visited_max = max(visited_max, lst[i] - lst[i - X]) | ||
else: | ||
if visited_max == lst[i]: | ||
cnt += 1 | ||
elif visited_max < lst[i] - lst[i - X]: | ||
cnt = 1 | ||
visited_max = max(visited_max, lst[i]) | ||
if visited_max == 0: | ||
print("SAD") | ||
else: | ||
print(visited_max) | ||
print(cnt) |