**Breaking the Records**

### Problem Statement :

Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there. For example, assume her scores for the season are represented in the array scores=[12, 24, 10, 24]. Scores are in the same order as the games played. She would tabulate her results as follows: Count Game Score Minimum Maximum Min Max 0 12 12 12 0 0 1 24 12 24 0 1 2 10 10 24 1 1 3 24 10 24 1 1 Given the scores for a season, find and print the number of times Maria breaks her records for most and least points scored during the season. Function Description Complete the breakingRecords function in the editor below. It must return an integer array containing the numbers of times she broke her records. Index 0 is for breaking most points records, and index 1 is for breaking least points records. breakingRecords has the following parameter(s): scores: an array of integers Input Format The first line contains an integer n, the number of games. The second line contains n space-separated integers describing the respective values of score0, score1, ....., score n-1. Constraints 1 <= n <= `1000 0 <= scores[i] <= `10^8 Output Format Print two space-seperated integers describing the respective numbers of times the best (highest) score increased and the worst (lowest) score decreased.

### Solution :

` ````
Solution in C :
C :
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int n;
scanf("%d",&n);
int a[10000];
for(int score_i = 0; score_i < n; score_i++){
scanf("%d",&a[score_i]);
}
int i,min,max,c1,c2;
min=a[0];
max=a[0];
c1=0;
c2=0;
for(i=1;i<n;i++)
{
if(a[i]>max)
{
c1++;
max=a[i];
}
if(a[i]<min)
{
c2++;
min=a[i];
}
}
printf("%d %d\n",c1,c2);
// your code goes here
return 0;
}
C++ :
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 10000007
#define pb push_back
#define S second
#define pb push_back
#define mp make_pair
#define INF 1e18
#define fr(i,j,k) for(ll i=j;i<=k;i++)
#define frd(i,j,k) for(ll i=j;i>=k;i--)
#define F first
#define sd(n) scanf("%lld",&n)
#define pd(n) printf("%lld\n",n)
#define db double
#define mod 1000000007
#define pii pair<ll,ll>
int main()
{
ll n;
cin>>n;
ll mx;
cin>>mx;
ll mn=mx;
ll a1=0,a2=0;
n--;
ll x;
while(n--)
{
cin>>x;
if(x>mx)
a1++;
if(x<mn)
a2++;
mx=max(mx,x);
mn=min(mn,x);
}
cout<<a1<<" "<<a2<<endl;
}
Java :
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] score = new int[n];
for(int score_i=0; score_i < n; score_i++){
score[score_i] = in.nextInt();
}
// your code goes here
int most = score[0];
int least = score[0];
int mr = 0;
int lr = 0;
for( int i = 1; i < n; i++ ){
if( score[i] > most ){
mr++;
most = score[i];
}
if( score[i] < least ){
lr++;
least = score[i];
}
}
System.out.print(mr + " " + lr);
}
}
python3 :
input()
a = list(map(int, input().split()))
m = M = a[0]
x = y = 0
for i in a[1:]:
if i > M:
M = i
x += 1
elif i < m:
m = i
y += 1
print(x, y)
```

## View More Similar Problems

## Jenny's Subtrees

Jenny loves experimenting with trees. Her favorite tree has n nodes connected by n - 1 edges, and each edge is ` unit in length. She wants to cut a subtree (i.e., a connected part of the original tree) of radius r from this tree by performing the following two steps: 1. Choose a node, x , from the tree. 2. Cut a subtree consisting of all nodes which are not further than r units from node x .

View Solution →## Tree Coordinates

We consider metric space to be a pair, , where is a set and such that the following conditions hold: where is the distance between points and . Let's define the product of two metric spaces, , to be such that: , where , . So, it follows logically that is also a metric space. We then define squared metric space, , to be the product of a metric space multiplied with itself: . For

View Solution →## Array Pairs

Consider an array of n integers, A = [ a1, a2, . . . . an] . Find and print the total number of (i , j) pairs such that ai * aj <= max(ai, ai+1, . . . aj) where i < j. Input Format The first line contains an integer, n , denoting the number of elements in the array. The second line consists of n space-separated integers describing the respective values of a1, a2 , . . . an .

View Solution →## Self Balancing Tree

An AVL tree (Georgy Adelson-Velsky and Landis' tree, named after the inventors) is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property. We define balance factor for each node as : balanceFactor = height(left subtree) - height(righ

View Solution →## Array and simple queries

Given two numbers N and M. N indicates the number of elements in the array A[](1-indexed) and M indicates number of queries. You need to perform two types of queries on the array A[] . You are given queries. Queries can be of two types, type 1 and type 2. Type 1 queries are represented as 1 i j : Modify the given array by removing elements from i to j and adding them to the front. Ty

View Solution →## Median Updates

The median M of numbers is defined as the middle number after sorting them in order if M is odd. Or it is the average of the middle two numbers if M is even. You start with an empty number list. Then, you can add numbers to the list, or remove existing numbers from it. After each add or remove operation, output the median. Input: The first line is an integer, N , that indicates the number o

View Solution →