A - George and Accommodation
Problem description
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex.
Input
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of rooms.
The i-th of the next n lines contains two integers pi and qi (0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in the i-th room and the room's capacity.
Output
Print a single integer — the number of rooms where George and Alex can move in.
Examples
Input
3
1 1
2 2
3 3
Output
0
Input
3
1 10
0 10
10 10
Output
2
解题思路:统计房间内剩余人数不小于2的房间总数(两个人住在同一间),水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,p,q,num=;
cin>>n;
while(n--){
cin>>p>>q;
if(q-p>=)num++;
}
cout<<num<<endl;
return ;
}
A - George and Accommodation的更多相关文章
- cf467A George and Accommodation
A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes input s ...
- CF467 AB 水题
Codeforces Round #267 (Div. 2) (C和D的题解单独写:CF467C George and Job (DP) CF467D Fedor and Essay 建图DFS) C ...
- Codeforces Round #267 (Div. 2) A
题目: A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes inp ...
- codeforces467-A水题
题目链接:http://codeforces.com/problemset/problem/467/A A. George and Accommodation time limit per test ...
- CF467C George and Job (DP)
Codeforces Round #267 (Div. 2) C. George and Job time limit per test 1 second memory limit per test ...
- Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
- Codeforces 467C George and Job(DP)
题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released ...
- Codeforces Round #267 (Div. 2) C. George and Job DP
C. George and Job The new ITone 6 has been released ...
- HDU 4118 Holiday's Accommodation
Holiday's Accommodation Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 200000/200000 K (Jav ...
随机推荐
- X509 颁发者和使用者 详解
CN=公用名称C=国家ST=省份L =城市或者区域O=组织名称OU=组织单位名称
- eas之视图冻结与解冻
// 冻结视图 table.getViewManager().freeze(verticalIndex, horizonIndex); //冻结视图:该方法在table还没显示的时候使用,也就是该方法 ...
- (C/C++学习)1.C++中vector的使用
说明:vector是C++中一个非常方便的容器类,它用于存放类型相同的元素,利用成员函数及相关函数可以方便的对元素进行增加或删除,排序或逆序等等,下面将对这些功能一一叙述. 一.vector的第一种用 ...
- layui 导出excel复杂表头
众所周知 layui的导出功能很好用,但是今天我要给大家推荐一个更好用的 大家来到这里想必也是因为layui无法满足 [导出Excle复杂表头] 的业务需求而来,这里废话不多说但还是强调一点,如果你是 ...
- 目录-Linux
Linux文件系统: Linux: glibc 程序编译方式: 动态链接 静态编译 进程的类型: 终端:硬件设备,关联一个用户接口 与终端相关:通过终端启动 与终端无关:操作引导启动过程当中自动启动 ...
- 爬虫系列(二) Chrome抓包分析
在这篇文章中,我们将尝试使用直观的网页分析工具(Chrome 开发者工具)对网页进行抓包分析,更加深入的了解网络爬虫的本质与内涵 1.测试环境 浏览器:Chrome 浏览器 浏览器版本:67.0.33 ...
- win安装配置Java8环境
这里就不重复造轮子,搜索一下. 一堆就出来 这里就引用一个百度知道的经验 https://jingyan.baidu.com/article/48b558e3f135687f38c09a03.html ...
- 2019-05-14 Python SSL
解决SSL报错问题 -- 导库 import ssl import urllib.request context = ssl._create_unverified_context() --用urlli ...
- 【hihocoder 1296】数论三·约瑟夫问题
[题目链接]:http://hihocoder.com/problemset/problem/1296 [题意] [题解] [Number Of WA] 0 [完整代码] #include <b ...
- docker 容器操作( 以 tomcat 为例 )
一.容器操作 一个镜像可以启动多个容器.比如一个 tomcat 镜像,可以启动多个tomcat 容器,启动后的这些 tomcat 都是各自独立的 二.步骤 1.搜索镜像 [root@localhost ...