Algorithm


Problem Name: beecrowd | 2863

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

Umil Bolt

 

By Ricardo Martins, IFSULDEMINAS BR Brazil

Timelimit: 1

Umil Bolt is an excellent runner. His specialty is the 100-meter race. Every day, he makes a battery of attempts to run this test in an ever faster time. It can be seen that, depending on the number of attempts, its performance improves or worsens. About this, he asks for your help to calculate the fastest attempt of each daily battery.

 

Input

 

The input is composed of several test cases. The first line of each test case contains an integer T (2 <= T <= 99) relative to the number of trials of a day. The following T lines contain a real number Ti (9 <= Ti <= 11) relative to the time, in seconds, of the ith battery attempt. The entry ends with end of file.

 

Output

 

For each test case of your program entry, you must print a real number containing the time of the fastest attempt of each battery.

 

 

 

Input Sample Output Sample

2
9.81
9.71
3
9.82
9.72
9.92

9.71
9.72

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>

int main (void)
{

	int casos;
	float numero, menor;

	while (scanf("%d", &casos) != EOF)
	{

		menor = 100.0f;
		for (int i = 0; i  <  casos; ++i)
		{
			scanf("%f", &numero);
			if (numero  <  menor)
				menor = numero;

		}

		printf("%.2f\n", menor);

	}

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2 9.81 9.71 3 9.82 9.72 9.92

Output

x
+
cmd
9.71 9.72

#2 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    while (cin >> n)
    {
        vector < double>v(n);
        double m;
        for (int i = 0; i  <  n; ++i)
        {
            cin >> v[i];
            if (i==0)
                m=v[i];
            else
            {
                if (v[i]  <  m)
                    m=v[i];
            }
        }
        cout << m << endl;
    }

    return 0;
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
2 9.81 9.71 3 9.82 9.72 9.92

Output

x
+
cmd
9.71 9.72

#3 Code Example with Java Programming

Code - Java Programming


import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
         Scanner leitor = new Scanner(System.in);
        while (leitor.hasNext()) {
        	int T = leitor.nextInt();
        	double melhor = 999;
        	for (int i = 0; i  <  T; i++) {
        		double t = leitor.nextDouble();
        		if (t  <  melhor) melhor = t;
        	}
        	System.out.println(melhor);
        }
    }
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
2 9.81 9.71 3 9.82 9.72 9.92

Output

x
+
cmd
9.71 9.72

#4 Code Example with Javascript Programming

Code - Javascript Programming


const { createReadStream } = require("node:fs")
const { createInterface } = require("node:readline")

//// READING FILE | STREAMS ////
class LineReader {
	/**
	 * @param {import("node:fs").PathLike} path
	 * @param {BufferEncoding} encoding
	 * @return {import("node:readline").ReadLine}
	 */
	static createReadLineInterface(path, encoding = "utf8") {
		const readStreamOptions = {
			encoding: encoding,
			flags: "r",
			emitClose: true,
			autoClose: true
		}

		return createInterface({
			input: createReadStream(path, readStreamOptions),
			crlfDelay: Infinity,
			terminal: false
		})
	}

	/**
	 * @param {import("node:fs").PathLike} path
	 * @param {BufferEncoding} encoding
	 */
	static create(path, encoding) {
		const RLI = LineReader.createReadLineInterface(path, encoding)

		let EOF = false

		const nextLineGenerator = (async function* () {
			for await (const line of RLI)
				yield line
		})()

		RLI.once("close", () => { EOF = true })

		return {
			hasNextLine: () => !EOF,
			nextLine: async (/** @type {unknown} */ fn) => {
				const { value } = (await nextLineGenerator.next())
				return (typeof fn === "function") ? fn(value) : value
			},
			close: () => RLI.close()
		}
	}
}

async function main() {
	const PATH = "/dev/stdin"
	const ENCODING = "utf8"

	const output = []
	const lineReader = LineReader.create(PATH, ENCODING)

	const helper = (line = "") => Number.parseFloat(line)
	const nextLine = lineReader.nextLine.bind(undefined, helper)

	while (lineReader.hasNextLine()) {
		const tries = await nextLine()
		let fastestTime = Number.POSITIVE_INFINITY

		if (Number.isNaN(tries)) break // EOF

		for (let t = 1; t  < = tries; t++) {
			const currentTime = await nextLine()
			fastestTime = Math.min(fastestTime, currentTime)
		}

		output.push(fastestTime.toFixed(2))
	}

	if (lineReader.hasNextLine())
		lineReader.close()

	console.log(output.join("\n"))
}

main()

Copy The Code & Try With Live Editor

Input

x
+
cmd
2 9.81 9.71 3 9.82 9.72 9.92

Output

x
+
cmd
9.71 9.72

#5 Code Example with Python Programming

Code - Python Programming


while True:
    try:
        n = int(input())
        tempo = 100.0
        while n > 0:
            t = float(input())
            if t < tempo:
                tempo = t
            n -= 1
        print(tempo)

    except EOFError:
        break

Copy The Code & Try With Live Editor

Input

x
+
cmd
2 9.81 9.71 3 9.82 9.72 9.92

Output

x
+
cmd
9.71 9.72
Advertisements

Demonstration


Previous
#2862 Beecrowd Online Judge Solution 2862 Insect! Solution in C, C++, Java, Js and Python
Next
#2867 Beecrowd Online Judge Solution 2867 Digits Solution in C, C++, Java, Js and Python