1、http://acm.hdu.edu.cn/showproblem.php?pid=2600
2、題目大意:
給出一個區間pq
後邊給出n個區間,最後輸出沒有被覆蓋的最大的值
3、題目:
War
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1825 Accepted Submission(s): 668
War is also a cultural entity, and its practice is not linked to any single type of political organisation or society. Rather, as discussed by John Keegan in his “History Of Warfare”, war is a universal phenomenon whose form and scope is defined by the society that wages it.
Today we don't want to talk about war, rather than , I want you to tell me which year there was no war.
Each war described as follows:
Ai Bi Ni (A,B is integer, p <= A, B <= q, Ni is a String which is the ith war's name )
Represent that the ith War took place between year A and year B.
4、AC代碼:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[30];
struct node
{
int x;
int y;
}a[105];
int cmp(node a,node b)
{
return a.x<b.x;
}
int main()
{
int n,p,q,b,c;
while(scanf("%d",&n)!=EOF)
{
scanf("%d%d",&p,&q);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
gets(s);
}
sort(a+1,a+n+1,cmp);
int cnt=-16000000;
int m=a[1].y;
for(int i=2;i<=n;i++)
{
if(a[i].x>a[i-1].y+1)
{
cnt=a[i].x-1;
//printf("cnt=%d\n",cnt);
}
if(a[i].y>m)
m=a[i].y;
}
if(m<q)
printf("%d\n",q);
else if(cnt!=-16000000)
{
printf("%d\n",cnt);
}
else
{
printf("Badly!\n");
}
}
return 0;
}