Write an algorithm to help the manager find the number of products that have negative temperature storage requirements.

0

We emphasize the submission of a fully working code over partially correct but efficient code. Once submitted, you cannot review this problem again. You can use printf() to debug your code. The printf() may not work in case of syntax/runtime error. The version of GCC being used is 5.5.0.

A cold storage company has N storage units for various products. The company has received N orders that must be preserved at respective N temperatures inside the storage units. The company manager wishes to identify which products must be preserved at negative temperatures.

Write an algorithm to help the manager find the number of products that have negative temperature storage requirements.

Write an algorithm to help the manager find the number of products that have negative temperature storage requirements.
Write an algorithm to help the manager find the number of products that have negative temperature storage requirements.


Input

The first line of the input consists of an integer numOfProducts, representing the number of products (N).
The second line consists of N space-separated integers - temperature0, temperature1,..... , temperatureN-1 representing the temperatures at which the products must be preserved in the storage units.

Output

Print an integer representing the number of products that must be preserved at negative temperatures.

Constraints

0 ≤ numOfProducts ≤ 106
-106 ≤ temperaturei ≤ 106
0 ≤ i < numOfProducts

Example

Input

7
9 -3 8 -6 -7 8 10

Output

3

Explanation:

The products that must be preserved at negative temperatures are at indices [1,3,4] i.e. [-3, -6, -7].
👇Programming language is C 👇
#include stdio .h="">

int main() {
    int n;
    scanf("%d", &n); // Read the number of products

    int temperatures[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &temperatures[i]); // Read the temperatures
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (temperatures[i] < 0) {
            count++; // Increment count if temperature is negative
        }
    }

    printf("%d\n", count); // Print the count of negative temperature products
    return 0;
}

Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !