http://codeforces.com/problemset/problem/673/B
题意:
Codeforces出题有 Div1 和 Div2 等级,D1中最简单的题目也要比 D2中的难(雨神说我现在的水平做不出来Div1的题)。
给定一些相似的题目,问可以出多少套题目,
数字代表难度(越大越难)。
思路:
模拟试一下,参考官方的题解。
Code:
#include<cstdio>
#include<cstring>
const int MYDD=1103;
int MAX(int x,int y) {
return x>y? x:y;
}
int MIN(int x,int y) {
return x<y? x:y;
}
int main() {
int n,m;
while(scanf("%d%d",&n,&m)!=EOF) {
int div1=n,div2=1;//div1题目等级高
int max,min;
while(m--) {
int a,b;
scanf("%d%d",&a,&b);//类似的题目
min=MIN(a,b);
max=MAX(a,b);
div1=MIN(div1,max);//div1题目中最简单的题目
div2=MAX(div2,min);//div2题目中最难的题目
}
if(div1-div2<0) {//难题中最简单的题目没有容易题中最难的难
puts("0");
} else {
printf("%d\n",div1-div2);
}
}
return 0;
}
/*By: Shyazhut*/