B. Draw!

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	while(cin >> n){
		int a,b,m=0,ans=0;
		while(n--){
			cin >> a >> b;
			if(min(a,b) >= m)ans += min(a,b) - m + 1;
			if(a == b) m = a+1;
			else m = max(a,b);
		}
		cout << ans << endl;
	}
	return 0;
}

 

相关文章:

  • 2021-10-01
  • 2021-12-30
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-06-09
猜你喜欢
  • 2021-12-24
  • 2021-07-13
  • 2022-02-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案