化式子,然后两个指针平\(A\)过去

#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#define R(a,b,c) for(register int a = (b); a <= (c); ++a)
#define nR(a,b,c) for(register int a = (b); a >= (c); --a)
#define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
#define MP make_pair
#ifdef QWQ
#define D_e_Line printf("\n------\n")
#define D_e(x) cerr << (#x) << " " << x << endl
#define C_e(x) cout << (#x) << " " << x << endl
#define FileOpen() freopen("in.txt", "r", stdin)
#define FileSave() freopen("out.txt", "w", stdout)
#define Pause() system("pause")
#include <cassert>
#define PASS fprintf(stderr, "Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#else
#define D_e_Line
#define D_e(x)
#define C_e(x)
#define FileOpen()
#define FileSave()
#define Pause()
#define PASS
#endif
using namespace std;
struct FastIO {
template<typename ATP> inline FastIO& operator >> (ATP &x) {
x = 0; int sign = 1; char c;
for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') sign = -1;
while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
if(sign == -1) x = -x;
return *this;
}
} io;
template<typename ATP> inline ATP Max(ATP x, ATP y) {
return x > y ? x : y;
}
template<typename ATP> inline ATP Min(ATP x, ATP y) {
return x < y ? x : y;
}
template<typename ATP> inline ATP Abs(ATP x) {
return x < 0 ? -x : x;
}
const int N = 5007;
#define int long long
struct nod {
int x, y, s;
// nod() {}
// nod(int _x, int _s) : x(_x), s(_s) {}
} x[N], y[N];
#undef int
int main() {
FileOpen();
#define int long long
int n, A, B, C;
io >> n >> A >> B >> C;
R(i,1,n){
io >> x[i].x >> x[i].y;
x[i].s = A * x[i].x + B * x[i].y;
y[i] = x[i];
}
sort(x + 1, x + n + 1, [&](const nod &a, const nod &b){ return a.x < b.x;});
sort(y + 1, y + n + 1, [&](const nod &a, const nod &b){ return a.s < b.s;});
int ans = 0;
R(i,1,n){
int minY = x[i].y, maxY = x[i].y + C / B;
int l = 1, r = 0, tot = 0;
R(j,1,n){
int minX = x[j].x, Smax = minX * A + minY * B + C;
while(r < n && y[r + 1].s <= Smax){
++r;
if(minY <= y[r].y && y[r].y <= maxY) ++tot;
}
while(l <= n && x[l].x < minX){
if(minY <= x[l].y && x[l].y <= maxY) --tot;
++l;
}
ans = Max(ans, tot);
}
}
printf("%lld", ans);
return 0;
}

LuoguP4165 [SCOI2007]组队的更多相关文章

  1. BZOJ 1071 [SCOI2007]组队

    1071: [SCOI2007]组队 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 1330  Solved: 417[Submit][Status][ ...

  2. bzoj1071[SCOI2007]组队

    1071: [SCOI2007]组队 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 2472  Solved: 792[Submit][Status][ ...

  3. 【BZOJ1071】[SCOI2007]组队(神仙题)

    [BZOJ1071][SCOI2007]组队(神仙题) 题面 BZOJ 洛谷 题解 首先把式子整理一下,也就是\(A*h+B*v\le C+A*minH+B*minV\) 我们正常能够想到的做法是钦定 ...

  4. 1071: [SCOI2007]组队

    1071: [SCOI2007]组队 https://lydsy.com/JudgeOnline/problem.php?id=1071 分析: dp+单调性. A*(hi–minH)+B*(si–m ...

  5. [SCOI2007]组队 差分

    题面:[SCOI2007]组队 题解: 一开始固定H然后找性质找了很久也没有找到任何有用的东西...... 然后大佬告诉我一个神奇的方法... 首先我们化一波式子: 设$H$表示高度的最小值,$V$表 ...

  6. 1071: [SCOI2007]组队 - BZOJ

    Description NBA每年都有球员选秀环节.通常用速度和身高两项数据来衡量一个篮球运动员的基本素质.假如一支球队里速度最慢的球员速度为minV,身高最矮的球员高度为minH,那么这支球队的所有 ...

  7. BZOJ.1071.[SCOI2007]组队(思路)

    题目链接 三个限制: \(Ah-AminH+Bv-BminV\leq C\ \to\ Ah+Bv\leq C+AminH+BminV\) \(v\geq minV\) \(h\geq minH\) 记 ...

  8. BZOJ1071: [SCOI2007]组队【双指针】【思维好题】

    Description NBA每年都有球员选秀环节.通常用速度和身高两项数据来衡量一个篮球运动员的基本素质.假如一支球队里速度最慢的球员速度为minV,身高最矮的球员高度为minH,那么这支球队的所有 ...

  9. [SCOI2007]组队

    嘟嘟嘟 这题有人说部分分O(n3)暴力,然而我暴力都没写过,调了半天也没用……还是看题解吧 首先,咱把A * ( h – minH ) + B * ( s – minS ) <= C 变个型,得 ...

随机推荐

  1. el-form 中的数组表单验证(数组可动态添加删除)

    除了一些简单的表单验证之外,我们还会有一些稍微复杂点的多层级表单的验证,如下图所示可点击添加,删除对数组进行操作,当点击确定时需要验证每一条form-item不能为空 其tempalte部分主要代码如 ...

  2. AntdVue使用

    AntdVue使用 配置与安装 #安装 npm install ant-design-vue --save #按需加载 import { Button, Layout, Row, Col, Menu, ...

  3. 13. L1,L2范数

    讲的言简意赅,本人懒,顺手转载过来:https://www.cnblogs.com/lhfhaifeng/p/10671349.html

  4. ExtJS 布局-Accordion布局(Accordion layout)

    更新记录: 2022年6月2日 开始. 2022年6月3日 发布. 1.说明 accordion(手风琴)布局一次仅显示一个子组件,内置支持 折叠 和 展开.当需要堆叠多个子组件,并每次只显示一次时, ...

  5. Boogie's First Blog

    这是boogie在博客园的第一篇随笔,祝大家身体健康,心情愉悦.

  6. 敲了几万行源码后,我给Mybatis画了张“全地图”

    作者:小傅哥 博客:https://bugstack.cn 沉淀.分享.成长,让自己和他人都能有所收获! 一.说说:"产"后感受 有人跟我说,手写Spring难,手写Mybatis ...

  7. 关于各种Vue UI框架中加载进度条的正确使用

    这里拿MUSE UI 中的进度条举例 <mu-circular-progress :size="40" class="icon" v-if="i ...

  8. Ubuntu系统iptables安全防护整改计划

    端口开放 默认防火墙是开放所有端口的,如果拿来做应用服务器,就很危险,所以要把防火墙用起来,只将需要的端口开放,ubuntu用的是iptables防火墙. iptables处理流程 iptables ...

  9. bat-命令行安装软件

    批处理 执行的两种方式 1.直接右键以管理员身份运行 2.在管理员身份的cmd窗口中 .\xxx.bat 执行 区别 第一种方式 当前cmd默认路径为 C:\windows\system32 第二种方 ...

  10. 纪念我逝去的n个小时

    纪念我逝去的n个小时 某人的惨案要我擦屁股=.= #include <bits/stdc++.h> using namespace std; template<class T> ...