Algorithm


problem Link : https://www.codechef.com/problems/TODOLIST 

Problem

CodeChef recently revamped its practice page to make it easier for users to identify the next problems they should solve by introducing some new features:

  • Recent Contest Problems - contains only problems from the last 2 contests
  • Separate Un-Attempted, Attempted, and All tabs
  • Problem Difficulty Rating - the Recommended dropdown menu has various difficulty ranges so that you can attempt the problems most suited to your experience
  • Popular Topics and Tags

Like most users, Chef didn’t know that he could add problems to a personal to-do list by clicking on the magic '+' symbol on the top-right of each problem page. But once he found out about it, he went crazy and added loads of problems to his to-do list without looking at their difficulty rating.

Chef is a beginner and should ideally try and solve only problems with difficulty rating strictly less than 1000. Given a list of difficulty ratings for problems in the Chef’s to-do list, please help him identify how many of those problems Chef should remove from his to-do list, so that he is only left with problems of difficulty rating less than 1000.

Input Format

  • The first line of input will contain a single integer , the number of test cases. Then the testcases follow.
  • Each testcase consists of 2 lines of input.
  • The first line of input of each test case contains a single integer, , which is the total number of problems that the Chef has added to his to-do list.
  • The second line of input of each test case contains  space-separated integers �1,�2,…,��, which are the difficulty ratings for each problem in the to-do list.

Output Format

For each test case, output in a single line the number of problems that Chef will have to remove so that all remaining problems have a difficulty rating strictly less than 1000.

Constraints

  • 1≤�≤1000
  • 1≤�≤1000
  • 1≤��≤5000

Subtasks

  • Subtask 1 (100 points):
    • Original constraints

Sample 1:

Input
 
Output
 
5
3
800 1200 900
4
999 1000 1001 1002
5
1 2 2 2 5000
5
1000 1000 1000 1000 1000
3
900 700 800
1
3
1
5
0

Explanation:

Test case 1: Among the three difficulty ratings, Chef only needs to remove the problem with difficulty rating 1200, since it is ≥1000. So, the answer is 1.

Test case 2: Among the four difficulty ratings, Chef needs to remove the problems with difficulty ratings of 10001001, and 1002, since they are ≥1000. So, the answer is 3.

Test case 3: Among the five difficulty ratings, Chef needs to remove the problem with a difficulty rating of 5000, since it is ≥1000. So, the answer is 1.

Test case 4: Chef needs to remove all the five problems, since they are all rated ≥1000. So, the answer is 5.

Test case 5: Chef does not need to remove any problem, since they are all rated <1000. So, the answer is 0.

Code Examples

#1 Code Example with C Programming

Code - C Programming

  #include<stdio.h>
int main()
{
    int t, n, d;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        int count = 0;
        for (int i = 0; i  <  n; i++)
        {
            scanf("%d", &d);
            if (d >= 1000)
                count++;
        }
        printf("%d\n",count);
    } 
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
3
800 1200 900
4
999 1000 1001 1002
5
1 2 2 2 5000
5
1000 1000 1000 1000 1000
3
900 700 800

Output

x
+
cmd
1
3
1
5
0
Advertisements

Demonstration


CodeChef solution TODOLIST  - Problems in your to-do list Codechef solution  in C,C++

Previous
CodeChef solution THREETOPICS - The Three Topics Codechef solution in C,C++
Next
CodeChef solution FLOW007 - Reverse The Number Codechef solution in C,C++