티스토리 뷰
(예전 글)/PS
[ AtCoder ] Boot camp for Beginners - ( AGC 029 ) A - Irreversible operation
rejo 2024. 1. 29. 11:40
https://atcoder.jp/contests/agc029/tasks/agc029_a
A - Irreversible operation
AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.
atcoder.jp
s[i] 번째 문자가 W면, W를 왼쪽으로 가져가기 위해 i 번 만큼 flip 해야 한다.
이전에 W가 k번 나왔다면, i - k 번 만큼 flip 해야 한다.
import sys
input = sys.stdin.readline
s = input().rstrip()
result = 0
cnt = 0
for i in range(len(s)):
if s[i] == 'W':
result += i - cnt
cnt += 1
print(result)'(예전 글) > PS' 카테고리의 다른 글
| [ BOJ ] 1038 : 감소하는 수 ( GOLD 5 ) / Python (0) | 2024.01.30 |
|---|---|
| [ AtCoder ] Boot camp for Beginners - ( ABC 048 ) B - Between a and b ... (0) | 2024.01.29 |
| [ AtCoder ] Boot camp for Beginners - ( ABC 156 ) C - Rally (0) | 2024.01.29 |
| [ BOJ ] 6603 : 로또 ( SILVER 2 ) / Python (1) | 2024.01.29 |
| [ BOJ ] 10997 : 별 찍기 - 22 ( SILVER 2 ) / Python (0) | 2024.01.29 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- queue
- math
- 백준
- PS
- Greedy
- sparse_table
- BOJ
- ad_hoc
- Python
- C
- implementation
- BFS
- segment-tree
- Prefix-Sum
- lazy-propagation
- Sort
- DP
- backtracking
- java
- codeup
- stack
- bitmask
- lca
- C++
- number_theory
- knapsack
- string
- Binary-Search
- bruteforcing
- kmp
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함
