• hdu 4079 Happy Telephones


    Happy Telephones

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 199    Accepted Submission(s): 159


    Problem Description
    In the land of Eden, all phone conversations are happy ones. People complaining on the phone are immediately put in jail. To enforce this law, the police taps all phone conversations.
    The police wants to hire the approriate number of operators to listen to all conversations in a given period of time. Unfortunately, each of their operators can listen to one conversation only before needing a really long break to rest from the effort.
    As a contractor of the police department, you have been asked to provide a program capable of determining the required number of operators. If the program does not work correctly, you will be put in jail as well, along with all the unhappy complainers. Do you really want to end up there?
     
    
    
    Input
    Each test case starts with two integers denoting the number of phone calls N (1 <= N < 10 000) and the number of intervals M (1 <= M < 100). This is followed by N lines describing the telephone calls, each one consisting of four integers Source, Destination, Start and Duration. Source and Destination identify the pair of telephone numbers establishing the connection (0 <= Source, Destination <= 10 000 000). Start and Duration are the start time and duration of the call in seconds (1 <= Duration <= 10 000 and Start >= 0). You can safely assume that the sum of Start and Duration fits into a 32-bit signed integer.
    Afterwards follow M lines containing the time intervals the police are interested in, each on described by two integers Start and Duration, in the same format and with the same meaning and constraints as those in the telephone calls. The last test case is represented by N = M = 0 and must not be processed.
     
    
    
    Output
    For each of the M intervals of each test case, print the number of calls that are active during at least one second of the interval.
     
    
    
    Sample Input
    3 2
    3 4 2 5
    1 2 0 10
    6 5 5 8
    0 6
    8 2
    1 2
    8 9 0 10
    9 1
    10 1
    0 0
     
    
    
    Sample Output
    3
    2
    1
    0
     
    
    
    Source
     
    
    
    Recommend
    lcy

    //很简单的一题、我一开始就想复杂了
    //居然用上了线段树、离散化、、、还是错的方法
    //其实只要判断2条线段有没有交点
    //看到别人提交代码那么短、醒悟过来、、
    #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <queue> #include <cmath> #define N 10002 using namespace std; struct node { int x,y; }st[N]; int main() { int i,j,k; int n,m; int s,d,f,t; while(scanf("%d%d",&n,&m),n||m) { for(i=0;i<n;i++) { scanf("%d%d",&s,&d); scanf("%d%d",&f,&t); st[i].x=f;st[i].y=f+t; } for(i=0;i<m;i++) { scanf("%d%d",&f,&t);t=f+t; for(k=0,j=0;j<n;j++) { if(st[j].y>f&&st[j].x<t) k++; } printf("%d\n",k); } } return 0; }
  • 相关阅读:
    #Python#中国大学生实习-大数据分析
    PHP 数字转大写
    pdo封装2
    python tkinter组件学习
    微信小程序相关资料整理
    php任务管理器 —— Jobby
    linux 定时任务未执行php脚本
    centos中安装php7
    php资源列表
    给二维码(图片)添加文字(水印),让生成的二维码中间带logo
  • 原文地址:https://www.cnblogs.com/372465774y/p/2624528.html
Copyright © 2020-2023  润新知