Ancient Basketball
Time limit | 2 seconds |
Memory limit | 256Mb |
Input | stdin |
Output | stdout |
Legend
A few days ago, Byteland archaeologists found the scoreboard of the very first basketball game in Byteland. Because of the historical significance of the event Bytelanders want to reconstruct the results.
It is known that Byteland rules of basketball are similar to basketball rules nowadays:
- team earns 1 point for each goal scored from a free throw;
- team earns 2 points for a field goal;
- team earns 3 points for a goal scored from behind the three-point line.
It is also known that, if the distance between the hoop and the player who scored the goal does not exceed L, then the goal counts as a field goal. Otherwise, it counts as a three-point throw. Archaeologists ask you to find out the result of the game based on the information about scored goals.
Input format
First line of input contains two integers n (1 ≤ n ≤ 1000) and L (1 ≤ L ≤ 30): the number of recorded scored balls and the distance from the hoop to the three-point line.
Each of the n next lines contains two integer numbers ti (1 ≤ ti ≤ 2) and di (-1 ≤ di ≤ 50). If di ≥ 0 then player from the team ti scored a goal from distance di. If di = -1, player from team ti scored a goal from a free throw.
Output format
In the only line of output, print the result of the game: the number of points earned by first team and the number of score points earned by second team. Separate the numbers by a colon.
Sample 1
Input | Output |
---|---|
3 5 1 2 2 5 1 10 | 5:2 |
Sample 2
Input | Output |
---|---|
4 10 1 2 1 -1 1 20 1 20 | 9:0 |
#include <cstdio>
int score[3];
int main()
{
int n,l;
scanf("%d%d",&n,&l);
for (int i=1;i<n+1;i++)
{
int t,d;
scanf("%d%d",&t,&d);
if (d == -1)
score[t] ++;
else if (d <= l)
score[t] += 2;
else
score[t] += 3;
}
printf("%d:%d",score[1],score[2]);
return 0;
}