Algorithm


Problem Name: beecrowd | 2310

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2310

Volleyball

 

By Leonardo Fernandes, IFSC BR Brazil

Timelimit: 1

A volleyball coach would like to keep statistics about his team. In every game he keeps track of the number of services, blocks and attacks of each player, as well as how many of these services, blocks and attacks were successful (scored points). Your program must show, with two decimal points what is the total percentage of services, blocks and attacks by the whole team that were successful.

 

Input

 

Input starts with the number of players N (1 ≤ N ≤ 100), followed by the names of each of these players. Below the name of each player, two rows of integers are presented. In the first row, the numbers represent the service, blocks and attack attempts (0 ≤ S,B,A ≤ 10000) by the specific player. In the second row there is the number of these services, blocks and attacks (0 ≤ S1S; 0 ≤ B1B; 0 ≤ A1A) that were successful.

 

Output

 

The output must contain the total percentage of successful services, blocks and attacks by the whole team, with two digits after the decimal point, as shown in the example.

 

 

 

Input Sample Output Sample

3
Renan
10 20 12
1 10 9
Jonas
8 7 1
2 7 0
Edson
3 3 3
1 2 3

Pontos de Saque: 19.05 %.
Pontos de Bloqueio: 63.33 %.
Pontos de Ataque: 75.00 %.

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

struct info

{
    char str[100];
    int at[3];
    int su[3];
};

int main(void)

{
    int i, j, n, x=0, y=0, z=0, a=0, b=0, c=0;
    float p, q, r;

    scanf("%i", &n);

    struct info volly[n];

    for (i = 0; i  <  n; ++i)
    {
        scanf("%s", volly[i].str);

        for (j = 0; j  <  3; ++j)
            scanf("%i", &volly[i].at[j]);

        for (j = 0; j  <  3; ++j)
            scanf("%i", &volly[i].su[j]);
    }

    for (i = 0; i  <  n; ++i)
    {
        for (j = 0; j  <  3; ++j)
        {
            if (j==0)
            {
                x+=volly[i].at[j];
                a+=volly[i].su[j];
            }

            else if (j==1)
            {
                y+=volly[i].at[j];
                b+=volly[i].su[j];
            }

            else if (j==2)
            {
                z+=volly[i].at[j];
                c+=volly[i].su[j];
            }
        }
    }

    p=(a*100)/(float)x;
    q=(b*100)/(float)y;
    r=(c*100)/(float)z;

    printf("Pontos de Saque: %.2f %%.\nPontos de Bloqueio: %.2f %%.\nPontos de Ataque: %.2f %%.\n", p, q, r);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 Renan 10 20 12 1 10 9 Jonas 8 7 1 2 7 0 Edson 3 3 3 1 2 3

Output

x
+
cmd
Pontos de Saque: 19.05 %. Pontos de Bloqueio: 63.33 %. Pontos de Ataque: 75.00 %.

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <string>

int main(){
    int n, i;
    double sbaatemp[4], sbasuc[4],totalsbaat[4] = {}, totalsbasu[4] = {};
    std::string name, output[4] = {"Pontos de Saque: ", "Pontos de Bloqueio: ", "Pontos de Ataque: "};
    std::cin >> n; 
    while (n--) {
    std::cin >> name; 
    for (i = 0;i  <  3;i++) {
        std::cin >> sbaatemp[i];
        totalsbaat[i] += sbaatemp[i];
    }
    for (i = 0;i  <  3;i++) {
        std::cin >> sbasuc[i]; 
        totalsbasu[i] += sbasuc[i];
    }
    }
    for (i = 0;i  <  3;i++) {
        std::cout << output[i];
        std::cout.precision(2);
        std::cout.setf(std::ios::fixed);
        std::cout << (totalsbasu[i]*100)/totalsbaat[i] << " %." << std::endl;
        //totalsbaat[i] = 100
        //totalsbasu[i] = x
    }

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 Renan 10 20 12 1 10 9 Jonas 8 7 1 2 7 0 Edson 3 3 3 1 2 3

Output

x
+
cmd
Pontos de Saque: 19.05 %. Pontos de Bloqueio: 63.33 %. Pontos de Ataque: 75.00 %.

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
let number = parseInt(lines.shift());
let i = 0;
let SumA = 0;
let SumB = 0;
let SumS = 0;
let SumA1 = 0;
let SumB1 = 0;
let SumS1 = 0;

while(i  <  number){
  let name = lines.shift();
  let [S, B, A] = lines.shift().split(" ");
  let [S1, B1, A1] = lines.shift().split(" ");

  
  SumA += parseInt(A);
  SumB += parseInt(B);
  SumS += parseInt(S);
  SumA1 += parseInt(A1);
  SumB1 += parseInt(B1);
  SumS1 += parseInt(S1);
  i++;
}


console.log(`Pontos de Saque: ${((SumS1 * 100) / SumS).toFixed(2)} %.\nPontos de Bloqueio: ${((SumB1 * 100) / SumB).toFixed(2)} %.\nPontos de Ataque: ${((SumA1 * 100) / SumA).toFixed(2)} %.`)

Copy The Code & Try With Live Editor

Input

x
+
cmd
3 Renan 10 20 12 1 10 9 Jonas 8 7 1 2 7 0 Edson 3 3 3 1 2 3

Output

x
+
cmd
Pontos de Saque: 19.05 %. Pontos de Bloqueio: 63.33 %. Pontos de Ataque: 75.00 %.

#4 Code Example with Python Programming

Code - Python Programming


n = int(input())
t = [0, 0, 0]
s = [0, 0, 0]
while n > 0:
    n -= 1
    c = input()
    for i in range(1):
        l = [int(x) for x in input().split()]
        for x in range(3):
            t[x] += l[x]
        l = [int(x) for x in input().split()]
        for x in range(3):
            s[x] += l[x]
    
print('Pontos de Saque: %.2f %%.' % (100*(s[0]/t[0])))
print('Pontos de Bloqueio: %.2f %%.' % (100*(s[1]/t[1])))
print('Pontos de Ataque: %.2f %%.' % (100*(s[2]/t[2])))
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 Renan 10 20 12 1 10 9 Jonas 8 7 1 2 7 0 Edson 3 3 3 1 2 3

Output

x
+
cmd
Pontos de Saque: 19.05 %. Pontos de Bloqueio: 63.33 %. Pontos de Ataque: 75.00 %.
Advertisements

Demonstration


Previous
#2309 Beecrowd Online Judge Solution 2309 Truco Solution in C, C++, Java, Js and Python
Next
#2311 Beecrowd Online Judge Solution 2311 Diving Solution in C, C++, Java, Js and Python