• LuoguP4165 [SCOI2007]组队


    化式子,然后两个指针平(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("
    ------
    ")
    #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
    ",__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;
    } 
    

  • 相关阅读:
    Jquery 跨域问题
    Linux下scp的用法
    JZ2440_V3_内核驱动程序_点亮一个LED灯
    MATLAB GUIDE 上位机串口通信开发 绘制图形
    关于在DSP工程内数组、strnpy函数、atoi函数的使用心得
    Visio中手绘图形的填充
    Ubuntu16.04NFS配置与ARM开发板互传文件_挂载和卸载
    树莓派压力测试工具STui + Stress的使用
    如何将代码优雅的插入到word中
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11851931.html
Copyright © 2020-2023  润新知