Mục lục
A-Task Failed Successfully 1
B-Precondition 4
C-Giant Domino 5
D-Make 2-Regular Graph 6
E-LCM Sequence 7
F-Stocks 4 8
G-Degree Harmony 9
A-Task Failed Successfully
Problem Statement
Takahashi set task goals for N days.
He aimed to complete Ai tasks on day i(i ≤ i ≤ N),and actually completed Bi tasks.
Find the number of days when he completed more tasks than his goal.
Constraints
• 1 ≤ N ≤ 100
• 1 ≤ Ai , Bi ≤ 100
• All input values are integers.
Input
The input is given from Standard Input in the following format:
A1 B1
A2 B2
..
.
AN BN
Output
Output the answer.
Sample Input 1
2 8
5 5
5 4
6 7
1
Sample Output 1
Sample Input 2
1 1
1 1
1 1
1 1
1 1
Sample Output 2
Sample Input 3
1 6
2 5
3 4
4 3
5 2
6 1
Sample Output 3
Solution
1 # include < iostream >
2 using namespace std ;
2
3
4 int main () {
5 int n , a , b ;
6 cin >> n ;
7 int ans = 0;
8 for ( int i = 1; i <= n ; i ++) {
9 cin >> a >> b ;
10 if ( a < b ) ans ++;
11 }
12 cout << ans << endl ;
13 return 0;
14 }
3
B-Precondition
4
C-Giant Domino
5
D-Make 2-Regular Graph
6
E-LCM Sequence
7
F-Stocks 4
8
G-Degree Harmony