thumbnail
Codeforces Round 1049 (Div. 2)
链接:https://codeforces.com/contest/2140 A. Shift Sort 算法:     贪心。 思路:     手玩几组样例后发现每次只能将一个 [latex]1[/latex] 换到正确位置,直接找有几个 [latex]1[/late…
thumbnail
Codeforces Round 1047 (Div. 3)
链接:https://codeforces.com/contest/2137 A. Collatz Conjecture     这题读假了以为是找出全部的可能值。 算法:     模拟。 思路:     无。 关键代码: voi…
thumbnail
AtCoder Beginner Contest 422
链接:https://atcoder.jp/contests/abc422 A - Stage Clear 算法:     模拟。 思路:     无。 关键代码: void solve() { string s; cin >> s; if (s[2] >= '…
thumbnail
AtCoder Beginner Contest 421
链接:https://atcoder.jp/contests/abc421 A - Misdelivery 算法:     模拟。 思路:     无。 关键代码: void solve() { int n; cin >> n; vector<string> s(n); for (auto &x : s) cin >> x; int …
thumbnail
背包问题
    背包问题(Knapsack Problem)是经典的动态规划问题之一。它描述的是在容量有限的背包中,选择若干物品放入,使得总价值最大化。 01背包     01背包问题,就是给定 n 种物品,每种物品都有重量和价值,每种物品都只有一个。 求最大价值 题目链接:2. 01背包问题 - AcWing题库 …
thumbnail
动态规划题目详解
1.Vacations 链接:https://codeforces.com/problemset/problem/698/A 思路:     定义 [latex]dp[i][j][/latex] 为第 [latex]i[/latex] 天为 [latex]j[/latex] 时前 [latex]i[/late…
thumbnail
Codeforces Round 1039 (Div. 2)
链接:https://codeforces.com/contest/2128 A. Recycling Center 算法:     贪心、排序。 思路:     直接从最小的开始销毁。 关键代码: void solve() { ll n, c; cin >> n >> c; vector<ll> a(n); for (auto &x…