Codeforces Round #264 (Div. 2)
程序员文章站
2023-12-29 12:09:28
...
Codeforces Round #264 (Div. 2) 题目链接 A:注意特判正好的情况,其他就一个个去判断记录最大即可 B:扫一遍,不够的用钱去填即可,把多余能量记录下来 C:把主副对角线处理出来,然后黑白只能各选一个最大的放即可 D:转化为DAG最长路问题,每个数字记录
Codeforces Round #264 (Div. 2)
题目链接
A:注意特判正好的情况,其他就一个个去判断记录最大值即可
B:扫一遍,不够的用钱去填即可,把多余能量记录下来
C:把主副对角线处理出来,然后黑格白格只能各选一个最大的放即可
D:转化为DAG最长路问题,每个数字记录下在每个序列的位置,如果一个数字能放上去,那么肯定是每个序列上的数字都是在之前最末尾数字的后面
E:大力出奇迹,预处理出树,然后每次查询从当前位置一直往上找到一个符合的即可,如果没有符合的就是-1
代码:
A:
#include#include #include using namespace std; int n, s; int main() { scanf("%d%d", &n, &s); int x, y; int flag = 1; int ans = 0; for (int i = 0; i
B:#include#include const int N = 100005; typedef long long ll; int n; ll h[N]; int main() { scanf("%d", &n); for (int i = 1; i h[i - 1]) { ll need = h[i] - h[i - 1]; if (now >= need) { now -= need; } else { ans += need - now; now = 0; } } else { now += h[i - 1] - h[i]; } } printf("%lld\n", ans); return 0; }
C:#include#include const int N = 2005; typedef long long ll; int n; ll g[N][N], zhu[N + N], fu[N + N]; int main() { scanf("%d", &n); for (int i = 0; i
D:#include#include #include using namespace std; const int N = 1005; struct Num { int v[10], la; } num[N]; bool cmp(Num a, Num b) { return a.la
E:#include#include #include using namespace std; const int N = 100005; int n, q, val[N], f[N]; vector g[N]; void dfs(int u, int fa) { f[u] = fa; for (int i = 0; i 1) return u; u = f[u]; } return -1; } int main() { scanf("%d%d", &n, &q); for (int i = 1; i
推荐阅读
-
Codeforces Round #264 (Div. 2)
-
Codeforces Round #281 (Div. 2)_html/css_WEB-ITnose
-
codeforces Round #260(div2) E解题报告
-
Codeforces Round #259 (Div. 2) A B C 三连发_html/css_WEB-ITnose
-
Codeforces Round #281 (Div. 2) (A、B、C、D题)_html/css_WEB-ITnose
-
Codeforces Round #222 (Div. 2)
-
Codeforces Round #435 (Div. 2)-B. Mahmoud and Ehab and the bipartiteness
-
Codeforces Round #157 (Div. 1) C. Little Elephant and LCM (数学、dp)
-
Codeforces Round #279 (Div. 2) 解题报告_html/css_WEB-ITnose
-
Codeforces Round #340 (Div. 2)-E-XOR and Favorite Number(莫队)