본문 바로가기

전체 글

[코드포스 Practice9] E. RGB Substring (hard version) The only difference between easy and hard versions is the size of the input. easy 와 hard 버젼의 유일한 차이는 입력 크기이다. You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'. 너는 각 문자가 RGB로 이루어져 있고 n개의 문자로 구성된 문자열 s가 주어졌다. You are also given an integer k. Your task is to change the minimum number of characters in the initial string s so that after the changes there will be .. 더보기
[코드포스 Practice9] D. Minimum number of steps We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7. The string "ab" appears as a substring if there is a letter 'b' right after .. 더보기
[코드포스 Practice9] C. Treasure Hunt Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure. Bottle with potion has two values x and y written on it. These values define four moves which can be performed using the potion: Map shows that the position of Captain Bill the Hummingbird i.. 더보기
[코드포스 Practice9] B. New Year Garland Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands. Polycarp은 슬퍼요ㅠㅠ 왜냐면 새해가 며칠 이내로 오는데 도시에 눈이 안 내렸기 때문이에요. 그래서 새해 분위기를 내기 위해 그는 집을 몇 개의 garland로 꾸미기로 했다. The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and bl.. 더보기
[코드포스 Practice9] A. Water Buying Polycarp wants to cook a soup. To do it, he needs to buy exactly n liters of water. Polycarp은 스프를 요리하고 싶다. 그렇게 하기 위해서, 그는 정확히 n 리터의 물을 사야한다. There are only two types of water bottles in the nearby shop — 1-liter bottles and 2-liter bottles. There are infinitely many bottles of these two types in the shop. 근처 상점에는 오직 두 종류의 물병이 있다. -- 1L 물병과 2L 물병임. 가게에는 이 두 종류의 물병이 무한개 있다. The bottle of the first.. 더보기
[코드포스 Practice9] 후기 2020년의 첫 코포~ 닉네임 바꾼 건 19년도까지만 적용되는 것 같았는데 아직까지 바뀌지 않고 있다. 이제 내 색깔이 조금 부담스러워짐 아무튼.. 오늘 많이 안 떨렸다. 보통 심장이 침대에서 바운스 하는 느낌으로 문제 풀었는데 오늘은 침대에 꽁꽁 싸매뒀음. 긴장 안 하려고 무던히 애 썼다. A - 8분 B - 10분 C - x분 (40분정도 고민하다 D번으로 넘어감) D - x분 (20분정도 고민하다 C번으로 넘어감) E - x분 음.. A, B번까지는 빨리 풀어서 4솔브 되겠네! 생각했는데 C 틀리고 D틀리고 E틀렸다.. (ㅎㅎ) C는 8번 코포와 비슷한 수학문제인 것 같아서 순조롭게 풀었는데 자꾸 어디선가 틀렸고 결국 원인을 못 찾았다. D는.. 음.. 문제 이해는 했는데 어떻게 건드려야 할지 모르.. 더보기
3649 로봇 프로젝트 이야 이거 두용액 문제 아녀?? 왕년에 두 용액 문제 풀 때 피눈물 흘렸는데 이렇게 다시 보네. 그래서 두 용액 문제처럼 l이랑 r을 배열 끝을 가리키게 하고, 합과 비교해보면서 줄이고 싶으면 r을 늘리고 싶으면 l을 움직였다. 어제 본 깔쌈한 코드처럼 짜려 했는데 포인터가 양 끝에 있어가지구 그냥 내가 편한대로 짰다ㅋㅋ 바로 코드로 옮김 #include #include #include using namespace std; using i64 = long long; int main() { i64 m, n; scanf("%lld %lld", &m, &n); vector v(n); m *= 10000000; for(int i = 0; i < n; i++){ scanf("%lld", &v[i]); } sort(.. 더보기
1806 부분합 무난하게 풀었다. 배열의 요소가 10,000이하이고 길이가 100,000이라 합 구하다가 100퍼 터지기 때문에 합은 long long으로 만들어줬다. #include #include using namespace std; using i64 = long long; int main() { int n, s; scanf("%d %d", &n, &s); vector v(n); i64 allSum = 0; for(int i = 0; i < n; i++){ scanf("%d", &v[i]); allSum += v[i]; } int l = 0, r = 0; int ans = n; int count = 1; i64 sum = v[0]; while(l < n){ if(sum < s){ if(r == n-1) break; .. 더보기