202009-2リスク集団のスクリーニング

#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 10000;
int num1[maxn];
int num2[maxn];

int main()
{
    int n,k,t,xl,yl,xr,yr;
    cin>>n>>k>>t>>xl>>yl>>xr>>yr;
    int f=0;
    for(int i=0; i<n; i++)
    {
        int x,y;
        int maxx=-1;
        int t2=0;
        for(int j=0; j<t; j++)
        {
            cin>>x>>y;
            if(x>=xl&&x<=xr&&y>=yl&&y<=yr)
            {
                num1[i]++;
                f=1;
            }
            if(x>=xl&&x<=xr&&y>=yl&&y<=yr&&f==1)
            {
                t2++;
            }
            maxx= max(maxx, t2);
            if(x<xl||x>xr||y<yl||y>yr)
            {
                f=0;
                t2=0;
            }
        }
        num2[i] = maxx;
    }
    int ou1=0,ou2=0;
    for(int i=0; i<n; i++)
    {
        if(num1[i]>=1) ou1++;
        if(num2[i]>=k) ou2++;
    }
    printf("%d\n%d\n", ou1, ou2);
    return 0;
}

 

おすすめ

転載: blog.csdn.net/weixin_42137874/article/details/113462583