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 ...
随机推荐
- luogu P2852 [USACO06DEC]牛奶模式Milk Patterns 后缀数组 + Height数组 + 二分答案 + 扫描
后缀数组有一个十分有趣的性质: $height[rk[i]] >= height[rk[i-1]] - 1$ Code: #include <bits/stdc++.h> #d ...
- 15.5.1【Task实现细节】 生成的代码
还在吗?我们开始吧.由于深入讲解需上百页的篇幅,因此这里我不会讲得太深.但我会提 供足够的背景知识,以有助于你对整个结构的理解.之后可通过阅读我近些年来撰写的博客文章, 来了解更加错综复杂的细节,或简 ...
- tornado服务器运行django应用
在jumpserver项目中看到的 def main(): from django.core.wsgi import get_wsgi_application import tornado.wsgi ...
- D2007从win7升级到win10下的莫名其妙问题。
在win7下听说win10被推荐,于是升级到win10.结果使用d2007不能打开,出现莫名其妙的错误.把bin\bds.exe改名bds1.exe后居然可以启动了.一番折腾后,这把bds1.exe改 ...
- Spring 单例模式和多例模式
1.Spring中的对象默认都是 单例模式. 2.使用 @Scope("prototype") 注解来使对象成为多例模式. 3.通过@Autowired 注入的Service 或者 ...
- VIM 使用 匹配替换命令配合表达式 实现 递增替换
:let n=100 | g/while/s/\d/\=n / | let n=n+1 before 10 void *thread_function_1(void *arg) { 11 int i; ...
- mysql5.7忘记root密码
systemctl stop mysqld.service vi /etc/my.cnf [mysqld] skip-grant-tables skip-networking mysql -uroot ...
- Tomcat日志配置远程Syslog采集
http://blog.csdn.net/leizi191110211/article/details/51593748
- 《深入理解Android 卷III》第八章深入理解Android壁纸
<深入理解Android 卷III>即将公布,作者是张大伟. 此书填补了深入理解Android Framework卷中的一个主要空白,即Android Framework中和UI相关的部分 ...
- 不错的题目-n个数连接得到的最大值
这道题目还是很不错的 <[字符串排序]n个数连接得到最小或最大的多位整数> 题目 描述:设有n个正整数,将它们依次连成在一排,组成一个多位数,现在要求可能组成的多位数中最大的多位数是什么? ...