codeforces 467A George and Accommodation
来源:互联网 发布:后现代主义平面 知乎 编辑:程序博客网 时间:2024/05/23 19:13
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 haspi people living in it and the room can accommodateqi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex.
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 andqi(0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in thei-th room and the room's capacity.
Print a single integer — the number of rooms where George and Alex can move in.
31 12 23 3
0
31 100 1010 10
2
AC:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
int p[110],q[110],cha[110];
for(int i=0;i<n;i++)
{
scanf("%d%d",p+i,q+i);
cha[i]=q[i]-p[i];
}
int ans=0;
for(int i=0;i<n;i++)
if(cha[i]>=2)
ans++;
printf("%d\n",ans);
}
- Codeforces 467A George and Accommodation
- Codeforces 467A George and Accommodation(水题)
- Problem-467A-Codeforces-George and Accommodation
- codeforces 467A George and Accommodation
- 467A. George and Accommodation
- 467A - George and Accommodation
- codeforces 467A(George and Accommodation) Java
- CodeForces 467 A.George and Accommodation(水~)
- A. George and Accommodation
- CF 467A George and Accommodation
- CF 467A-George and Accommodation
- Codeforces Round #267 (Div. 2) A. George and Accommodation
- Codeforces刷题之路——467A George and Accommodation
- cf467A George and Accommodation
- Coderforces George and Accommodation
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- CodeForces 387A George and Sleep
- 关于js文本框数字校验
- 从写项目到部署linux服务器全过程-linux下安装JDK篇
- 基于mvc模式的应用框架之Hibernate(一)
- 如何用matplotlib画图并保存图像
- kotlin的lambda表达式
- codeforces 467A George and Accommodation
- 1154: 校门外的树
- 基于Jmeter和Testlink的自动化测试框架研究与实施
- ios审核被拒5.2.1
- display
- 《使用ArcGIS JavaScript API 开发Web 3D应用》学习笔记
- Wise Installation System使用纪要
- 写在年度总结前面
- dom4j