1720: Thanksgiving Day KK Session--Interview problemTime limit: 1 Sec memory limit: MB
Submissions: 303 Resolution: 44
Submitted State [Discussion Version]
Title Description
There are n people to interview the student Union XX Department, the interview process to ask any two of the time between the interviewer can not overlap. It is known how many people can be interviewed by the time the N interviewers arrive and the time they need to interview. XX of the department is a good friend of KK, and now he is looking for KK to help. But KK is very busy, please help KK. Time overlaps such as [1, 3] [2, 4] or [1, 3][3, 4]. input
Given an integer t, indicates that there is a T (t<=100) Group of test data. Each set of test data has an integer n (0<=n<=1000), followed by two integers per line s[i],t[i], indicating the time of the first interview and the time required for the interview. Output
Each line outputs an integer that represents the maximum number of people that can be interviewed. Sample Input
1
1
1 0
Sample Output
1
Tips
Source
Kk
Ac-code:
#include <cstdio>
#include <algorithm>
using namespace std;
struct node
{
int st,e;
} S[1005];
BOOL CMP (node A,node b)
{
return a.e<b.e;
}
int main ()
{
int t,n,i,a,ans,b;
scanf ("%d", &t);
while (t--)
{
scanf ("%d", &n);
if (n==0)
{
printf ("0\n");
Continue;
}
for (i=0;i<n;i++)
{
scanf ("%d%d", &s[i].st,&b);
s[i].e=s[i].st+b;
}
Sort (s,s+n,cmp);
A=S[0].E;
Ans=1;
for (i=1;i<n;i++)
if (s[i].st>a)
{
ans++;
A=S[I].E;
}
printf ("%d\n", ans);
}
return 0;
}