【Java每日一题,简单题】csp202203-3 风险人群筛查

Introduction

在这里插入图片描述

Input

在这里插入图片描述

Output

输出共两行,每行一个整数,分别表示经过高危区域的人数和曾在高危区域逗留的人数。

Sample

input

5 2 6 20 40 100 80
100 80 100 80 100 80 100 80 100 80 100 80
60 50 60 46 60 42 60 38 60 34 60 30
10 60 14 62 18 66 22 74 26 86 30 100
90 31 94 35 98 39 102 43 106 47 110 51
0 20 4 20 8 20 12 20 16 20 20 20

output

3
2

Solution

import java.util.Scanner;

public class Main20200902 {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int n=s.nextInt();
        int k=s.nextInt();
        int t=s.nextInt();
        int Xl=s.nextInt();int Yb=s.nextInt();int Xr=s.nextInt();int Yu=s.nextInt();
        int count,max;
        int num1=0;int num2=0;
        for(int i=0;i<n;i++){
            count=0;
            max=0;
            for(int j=0;j<t;j++){
                int x=s.nextInt();int y=s.nextInt();
                if(x>=Xl&&x<=Xr&&y>=Yb&&y<=Yu){
                    count++;
                    max=Math.max(max,count);
                }else {
                    count=0;
                }
            }
            if(max!=0)num1++;
            if(max>=k)num2++;
        }
        System.out.println(num1);
        System.out.println(num2);

    }
}

Experience

前年考试的时候,卡了我3个小时,没过,今天我花了10分钟就写出来了,哎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小梁说代码

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值