zoukankan      html  css  js  c++  java
  • CF 670C Cinema(算竞进阶习题)

    离散化+排序

    离散化统计人数就好,本来不难,但是测试点太丧心病狂了。。。CF还是大哥啊

    #include <bits/stdc++.h>
    #define INF 0x3f3f3f3f
    using namespace std;
    typedef long long ll;
    inline int lowbit(int x){ return x & (-x); }
    inline int read(){
        int X = 0, w = 0; char ch = 0;
        while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); }
        while(isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
        return w ? -X : X;
    }
    inline int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b; }
    inline int lcm(int a, int b){ return a / gcd(a, b) * b; }
    template<typename T>
    inline T max(T x, T y, T z){ return max(max(x, y), z); }
    template<typename T>
    inline T min(T x, T y, T z){ return min(min(x, y), z); }
    template<typename A, typename B, typename C>
    inline A fpow(A x, B p, C yql){
        A ans = 1;
        for(; p; p >>= 1, x = 1LL * x * x % yql)if(p & 1)ans = 1LL * x * ans % yql;
        return ans;
    }
    const int N = 200005;
    int a[N], b[N<<2], tot, num[N<<2];
    struct Film{
        int x, y, cnt1, cnt2, id;
        bool operator < (const Film &rhs) const {
            if(cnt1 != rhs.cnt1) return cnt1 > rhs.cnt1;
            if(cnt2 != rhs.cnt2) return cnt2 > rhs.cnt2;
            return id < rhs.id;
        }
    }film[N];
    int main(){
    
        int n = read();
        for(int i = 0; i < n; i ++) a[i] = read(), b[++tot] = a[i];
        int m = read();
        for(int i = 0; i < m; i ++) film[i].x = read(), b[++tot] = film[i].x, film[i].id = i;
        for(int i = 0; i < m; i ++) film[i].y = read(), b[++tot] = film[i].y;
        sort(b + 1, b + tot + 1);
        tot = unique(b + 1, b + tot + 1) - b - 1;
        for(int i = 0; i < n; i ++){
            num[lower_bound(b + 1, b + tot + 1, a[i]) - b] ++;
        }
        for(int i = 0; i < m; i ++){
            film[i].cnt1 = num[lower_bound(b + 1, b + tot + 1, film[i].x) - b];
            film[i].cnt2 = num[lower_bound(b + 1, b + tot + 1, film[i].y) - b];
        }
        sort(film, film + m);
        printf("%d
    ", film[0].id + 1);
        return 0;
    }
    
  • 相关阅读:
    linux中编写同步文件的脚本
    SSH实现免密登录
    关于ISO 15765-2的解读
    设置Tera Term
    串口通信有极限速度
    三相永磁电机电流采样
    eclipse中F3快捷键无法跳转到定义的解决方法
    电脑和航模杂志和电子开发网站汇总
    MC9S08DZ60经典单片机
    STM32的SWD调试
  • 原文地址:https://www.cnblogs.com/onionQAQ/p/10533850.html
Copyright © 2011-2022 走看看