![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LA
qq_38232157
这个作者很懒,什么都没留下…
展开
-
LA 3695 Distant Galaxy(训练指南, 枚举扫描)
算法竞赛训练指南,52页,枚举,线性扫描 本题要点: 1、每个点,先按x坐标排序, 算出单独的y左边有m个,然后遍历 y坐标的上届和下届 for(int a = 0; a < m; ++a) // 下届 { for(int b = a + 1; b < n; ++b) //上届 {} } 在上届和下届确定的情况下, 求出一个长方形包含最多的点数 2、几个数组的意义, 数组的坐标指的是,该点的x坐标,排在所有单独坐标的排名, 每一个单独坐标对应一条竖线: Left[MaxN] //Left[i原创 2020-05-24 23:21:02 · 131 阅读 · 0 评论 -
LA 2678 Subsequence (训练指南,尺取法)
算法竞赛训练指南, 48 页 注意: 1、尺取法,滑动窗口 [L, R] 使得区间内的数的和 大于等于 s , 然后更新最小的区间差值 R - L + 1 2、无解的时候,输出 0 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int MaxN = 100010; int n, s; int seq原创 2020-05-23 15:56:45 · 99 阅读 · 0 评论 -
LA3177 Beijing Guards (训练指南,贪心, 二分)
题意: n个人围成一圈,第i个人想要ri个不同的礼物,相邻的两个人礼物类型不能重复。 每种礼物不限量,求最少需要多少种礼物才行(1<=n<=100000) 训练指南, 37页。 分类讨论,n为偶数和奇数时。 n为偶数情况, p = max{r[i] + r[i + 1]} (1 <= i <= n) //记 r[n + 1] = r[1] 本题要点: 1、贪心来分析奇数情况 对应第一人,需要礼物 r[1], 用 r[1] 将 所有礼物分为两部分, 1 ~ r[1] 和 r[1] +原创 2020-05-16 22:34:05 · 162 阅读 · 0 评论 -
LA 4329 Ping pong (树状数组)
树状数组的典型应用, 参看 《算法笔记》 475页 对于有n个数的数组 A(A[1] ~ A[n]), 对于每一个元素,求出序列中,它的左边比它小的数的个数 本题要点: 1、 题目见,《训练指南》 197 页 2、 ans 要用 long long 3、 输入的数组个数最大值为 20000, 每个 a[i] 的最大值为 100000, 代码的 const int MaxN = 100010 //如果 const int MaxN = 20010, runtime error #include <cs原创 2020-05-15 01:47:44 · 105 阅读 · 0 评论 -
LA 3971 Assemble(二分查找,stl)
题目意思: 算法竞赛入门经典训练指南,18 页 本题要点: 1、求解 “最小值的最大”,常用二分查找 二分查找x, 判断是否有总价格不大于 b 的,而且配件最小因子都不小于 x的电脑。 2、 使用map 来存储 每种配件对应的 名字和id号 使用vector 来存储每种配件 的所有的类型 #include <cstdio> #include <cstring> #include <iostream> #include <vector> #include <原创 2020-05-13 23:24:27 · 152 阅读 · 0 评论