Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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:
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.
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.
Input: 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: 1
3
1
5
0
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 1000, 1001, 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.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t; cin >> t;
while(t--)
{
int n; cin >> n;
int cnt = 0;
for(int i = 0; i < n; ++i)
{
int x; cin >> x;
cnt += x >= 1000;
}
cout<<cnt<<"\n";
}
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner hello=new Scanner(System.in);
int T=hello.nextInt();
while(T>0){
T--;
int N=hello.nextInt();
int[] D=new int[N];
for(int i=0;i<N;i++){
D[i]=hello.nextInt();
}
int count=0;
for(int i=0;i<N;i++){
if(D[i]>=1000){
count++;
}
}
System.out.println(count);
}
}
}
# cook your dish here
for x in range(int(input ())):
l=int(input ())
c=0
a=list(map(int, input ().split()))
for i in a:
if i>=1000:
c=c+1
print(c)
In our experience, we suggest you solve this Problems in your to-do list CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Problems in your to-do list CodeChef Solution
I hope this Problems in your to-do list CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>