Redaksiya
For each type of toy, read its quantity and price. If the price is less than grn, add the number of such toys to the total count.
Algorithm realization
Read the number of toy types .
scanf("%d",&n);
Use the variable to store the total count of toys with a price less than grn.
res = 0;
Read and process the information about toys.
for(i = 0; i < n; i++) { scanf("%d %lf",&num,&price); if (price < 50.0) res += num; }
Print the answer.
printf("%d\n",res);
Java realization
import java.util.*; public class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); //con.useLocale(new Locale("US")); //con.useLocale(Locale.US); int res = 0; int n = con.nextInt(); for (int i = 0; i < n; i++) { int num = con.nextInt(); double price = con.nextDouble(); if (price < 50.0) res += num; } System.out.println(res); con.close(); } }
Python realization
Read the number of toy types .
n = int(input())
Use the variable to store the total count of toys with a price less than grn.
res = 0
Read and process the information about toys.
for _ in range(n): num, price = input().split() num = int(num) price = float(price) if price < 50.0: res += num
Print the answer.
print(res)