155A - I_love_username - CodeForces Solution


brute force *800

Please click on ads to support us..

Python Code:

n=int(input())
l=input().split()
low=int(l[0])
high=int(l[0])
c=0
for i in range(1,len(l)):
    if int(l[i])>high:
        high=int(l[i])
        c+=1
    elif int(l[i])<low:
        low=int(l[i])
        c+=1
print(c)

C++ Code:

#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k=0,i,j,min,max;
	cin>>n;
	int arr[n];
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	min=arr[0];
	max=arr[0];
	for(i=0;i<n;i++){
		for(j=0;j<i;j++){
			if(arr[j]<min){
				min=arr[j];	
			}
			if(arr[j]>max){
				max=arr[j];	
			}
		}
		if(arr[i]>max || arr[i]<min){
			k++;
		}
		
	}
	cout<<k;
	
}


Comments

Submit
1 Comments
  • 13/5/2024 13:20 - America/Los_Angeles

Alissa1743


More Questions

Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football