# 【Codeforces Round #351 Div. 2】 673B Problems for Round

There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors want to split problems between two division according to the following rules:
• Problemset of each division should be non-empty.
• Each problem should be used in exactly one division (yes, it is unusual requirement).
• Each problem used in division 1 should be harder than any problem used in division 2.
• If two problems are similar, they should be used in different divisions.
Your goal is count the number of ways to split problem between two divisions and satisfy all the rules. Two ways to split problems are considered to be different if there is at least one problem that belongs to division 1 in one of them and to division 2 in the other.
Note, that the relation of similarity is not transitive. That is, if problem i is similar to problem j and problem j is similar to problem k, it doesn’t follow that i is similar to k.

【题目分析】

【代码】

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
int lmax=1,rmin=n;
for (int i=1;i<=m;++i){
int u,v;
scanf("%d%d",&u,&v);
lmax=max(min(u,v),lmax);
rmin=min(max(u,v),rmin);
}
if (lmax>=rmin) {
printf("0\n"); return 0;
}
else {
printf("%d\n",rmin-lmax); return 0;
}
}

• 本文已收录于以下专栏：

## Codeforces Round #258 (Div. 2)-(A,B,C,D,E)

A:Game With Sticks 水题。。。每次操作，都会拿走一个横行，一个竖行。 所以一共会操作min（横行，竖行）次。 #include #include #include #include ...
• rowanhaoa
• 2014年07月25日 14:39
• 1481

## 【解题报告】Codeforces Round #401 (Div. 2)

• TRiddle
• 2017年02月25日 17:55
• 413

## Codeforces Round #395 (Div. 2)(ABCD)

ps:打完这场cf才知道自己真的很菜，还是停留在AB题的水平，有时候CD其实很简单，但就是想不到，别人一眼看出而我就是想不到，有时候想到了点子上但就是突破不了 题目链接：  Codeforc...
• qq_34731703
• 2017年02月03日 12:50
• 500

## Codeforces Round #460 (Div. 2) D. Substring（拓扑排序）

• cyf199775
• 2018年02月01日 13:55
• 42

## Codeforces Round #378 (Div. 2) E. Sleep in Class

• Fsss_7
• 2016年11月15日 13:48
• 359

## Codeforces Round #428 (Div. 2)：D. Winter is here（组合数公式）

D. Winter is here time limit per test 3 seconds memory limit per test 256 megabytes input stan...
• Jaihk662
• 2017年08月14日 14:52
• 349

## Codeforces Round #442 (Div. 2)

A. #include using namespace std; typedef long long ll; int main() { string s; cin >> s; ...
• Egqawkq
• 2017年10月24日 02:15
• 241

## Codeforces Round #427 (Div. 2) A B C D

A. Key races time limit per test 1 second memory limit per test 256 megabytes input standard i...
• sinat_35406909
• 2017年08月01日 02:03
• 699

## Codeforces Round #327 (div.2)(A B C D)

codeforces round #327 (div.2)
• lincifer
• 2015年10月26日 13:11
• 1095

## Codeforces Round #460 (Div. 2) D. Substring

• litmxs
• 2018年01月31日 23:25
• 67

举报原因： 您举报文章：【Codeforces Round #351 Div. 2】 673B Problems for Round 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)