化式子,然后两个指针平\(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. 安装vsFTP到CentOS(YUM)

    运行环境 系统版本:CentOS Linux release 7.3.1611 (Core) 软件版本:vsftpd-3.0.2 硬件要求:无 安装过程 1.安装YUM-EPEL存储库 YUM-EPE ...

  2. MongoDB 分片规则

    每日一句 生命本身毫无意义,只有死亡才能让你邃晓人性的真谛! 每日一句 Ideal is the beacon. Without ideal, there is no secure direction ...

  3. 拭目以待!JNPF .NET将更新.NET 6技术,同时上线 3.4.1 版本

    2022年5月30日,福建引迈即将上线JNPF开发平台的.NET 6版本,在产品性能上做了深度优化,且极大的提升了工作效率,加强了对云服务的改进升级,全面提升用户的使用体验. JNPF是一个以PaaS ...

  4. Redis - 读写模式 - 缓存一致性

    Cache Aside Pattern(旁路缓存模式) 读:从cache中读取数据,若读取到则直接返回:cache中不存在则去database中读取,然后更新到cache. 写:先更新database ...

  5. Xmind演讲主题大纲

    参考:https://www.bilibili.com/video/BV1Rb411s7VG?p=9

  6. redis持久化之RDB (七)

    一:什么是redis的持久化 Redis 持久化 Redis 提供了不同级别的持久化方式: RDB持久化方式能够在指定的时间间隔能对你的数据进行快照存储. AOF持久化方式记录每次对服务器写的操作,当 ...

  7. UiPathExcel写入操作

    一.Excel 写操作 1.写一个单元格 (1)控件介绍 Write Cell: 使用Write Cell控件,在指定单元格写入内容     常用属性介绍: Destination: Cell: 要写 ...

  8. 细说GaussDB(DWS)复杂多样的资源负载管理手段

    摘要:对于如此多的管控功能,管控起来实际的效果到底如何,本篇文章就基于当前最新版本,进行效果实测,并进行一定的分析说明. 本文分享自华为云社区<GaussDB(DWS) 资源负载管理:并发管控以 ...

  9. 如何搭建android源代码repo仓库

    如何搭建android源代码repo仓库 目录 如何搭建android源代码repo仓库 1 repo是如何管理仓库的? 1.1 repo如何工作的? 1.2 搭建repo服务需要做哪些事情? 2 部 ...

  10. 『现学现忘』Git后悔药 — 28、版本回退git reset --soft命令说明

    git reset --soft commit-id命令:回退到指定版本.(soft:柔软的) 该命令仅仅修改分支中的HEAD指针的位置,不会改变工作区与暂存区中的文件的版本. 实现上是只做了一件事情 ...