본문 바로가기

PS/AtCoder25

AtCoder Educational DP Contest A~E https://atcoder.jp/contests/dp/tasks Tasks - Educational DP Contest AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online. atcoder.jp A. i에서 i+1 or i+2로 전이할 수 있습니다. 즉 i는 i-1과 i-2에서 옵니다. dp[i]=max(dp[i-1]+C1 , dp[i-2]+C2) 임을 쉽게 알 수 있습니다. 시간복잡도는 O(N)입니다. #include using namespace std; int n, h[100005], dp[100005]; int main() { ios::sy.. 2022. 9. 9.
AtCoder ABC 257 D, E D. https://atcoder.jp/contests/abc257/tasks/abc257_d D - Jumping Takahashi 2 AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online. atcoder.jp 시작점을 잘 정해서 조건을 만족하도록 전부 순회할 수 있는지 그 때 최소의 S를 찾는 문제입니다. 시작점을 고정하고, S도 고정시킨 후 각 점에서 다른 모든 점으로 조건을 만족한다면 그래프 위에서 선분으로 연결해줍니다. 이 때, dfs를 쭉 해주고 나면 모든 점을 방문했는지 여부를 O(N)에 알 수 있습니다. 이제 시작점을 선택하는 경우 .. 2022. 9. 8.
AtCoder ABC 260 풀이 https://atcoder.jp/contests/abc260/tasks Tasks - AtCoder Beginner Contest 260 AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online. atcoder.jp A. 1개만 나오는 문자를 출력해주면 됩니다. s[0], s[1], s[2] 개수를 세주고 경우를 나누면 됩니다. #include using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); string s; cin >> s; int c1 = count(s.begin(), s.en.. 2022. 9. 3.
AtCoder ABC 261 풀이 https://atcoder.jp/contests/abc261/tasks Tasks - AtCoder Beginner Contest 261 AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online. atcoder.jp A. 두 선분이 겹치는 길이를 구해주면 됩니다. 1. 안 겹치는 경우 2. 1번이 앞에서 겹치는 경우 3. 2번이 앞에서 겹치는 경우 4. 1번이 2번 안에 있는 경우 5. 2번이 1번 안에 있는 경우 5가지를 조건문으로 처리해줍시다. #include using namespace std; int main() { ios::sync_with.. 2022. 9. 1.