zoukankan      html  css  js  c++  java
  • hiho 1612

    emmmmm?A不了?90分是什么鬼

    #include<cstdio>
    #include<cstdlib>
    #include<vector>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    using namespace std;
    const int maxn=400000;
    int h[maxn],w[maxn],num[maxn];
    int Max,Min;
    struct in
    {
        int c;
        int t;
    }p[maxn];
    int cmp(in a,in b){
        return a.t<b.t;
    }
    int main()
    {
        int n,m,i,j,k,ans=0;
        scanf("%d%d",&n,&m);
        for(i=1;i<=n;i++){
            scanf("%d%d",&p[i].t,&p[i].c);
        }
        for(i=1;i<=m;i++){
            scanf("%d",&j);
            w[j]=1;
        }
        sort(p+1,p+n+1,cmp);
        h[0]=m;Max=0;Min=0;
        for(i=1;i<n;i++){
            num[p[i].c]++;
            if(w[p[i].c]){
                if(Min==num[p[i].c]-1&&h[num[p[i].c]-1]==1) Min++;
                h[num[p[i].c]-1]--;
                h[num[p[i].c]]++;
            }
            else  Max=max(Max,num[p[i].c]);
            if(Min>Max) ans=ans+p[i+1].t-p[i].t;
        }
        printf("%d
    ",ans);
        return 0;
    }
  • 相关阅读:
    HTML页引用CSS
    C#反射
    Marshal.SecureStringToBSTR
    SQL语句创建表和数据库
    抽象类和抽象方法
    3 Sum Closest
    Chapter 2: Binary Search & Sorted Array
    Spiral Matrix
    Pascal's Triangle
    Plus One
  • 原文地址:https://www.cnblogs.com/hua-dong/p/7718562.html
Copyright © 2011-2022 走看看