Codeforces round #267 (Div. 2) A. George and accommodation

Source: Internet
Author: User

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 hasNRooms in total. At the momentI-Th room hasPIPeople living in it and the room can accommodateQIPeople 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 integerN(1? ≤?N? ≤? 100)-the number of rooms.

TheI-Th of the nextNLines contains two integersPIAndQI(0? ≤?PI? ≤?QI? ≤? 100)-the number of people who already live inI-Th room and the room's capacity.

Output

Print a single integer-the number of rooms where George and Alex can move in.

Sample test (s) Input
31 12 23 3
Output
0
Input
31 100 1010 10
Output
2. I have n dormitories, I can have a total of Qi and PI, and I can have two more dormitories. My thoughts are: directly calculate the big questions.
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int main() {int n;scanf("%d", &n);int p, q, ans = 0;for (int i = 0; i < n; i++) {scanf("%d%d", &q, &p);if (p - q >= 2)ans++;}printf("%d\n", ans);return 0;}

 

Codeforces round #267 (Div. 2) A. George and accommodation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.