Algorithm


Problem Name: beecrowd | 1858

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

Theon's Answer

 

By Ricardo Oliveira, UFPR BR Brazil

Timelimit: 1

Ramsay: "(...) you win the game if you figure out who I am and why I'm torturing you."

Theon must think quickly and guess who his torturer is! However, Ramsey already decided what he will do after Theon gives his answer.

There are N people Theon may say the torturer is. Let us consider that the people are numbered from 1 to N. If Theon answers the torturer is person i, Ramsay will hit him Ti times.

You task is to help Theon and determine what he should answer in order to minimize the number of times he will be hit.

 

Input

 

The first line contains an integer N (1 ≤ N ≤ 100). The second line contains N integers T1, T2, ..., TN (0 ≤ Ti ≤ 20).

 

Output

 

Print a single line containing the number of the person Theon must say the torturer is. If there is more than one possible answer, print the smallest one.

 

 

 

Input Samples Output Samples

3
8 0 7

2

 

 

 

2
1 1

1

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include<stdio.h>
int main()
{

    int i,j,k,l,m,n;
    while(scanf("%d",&n)!=EOF)
    {
        l=20;
        for(i = 0; i  <  n; i++)
        {
            scanf("%d",&m);
            if(m < l)
            {
                l=m;
                k=i+1;
            }
        }
        printf("%d\n",k>;
        k=0;
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 8 0 7

Output

x
+
cmd
2

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var N = parseInt(lines.shift());
var arr = lines.shift().split(' ').map(input=>parseInt(input));

var position = 0;
var smallest = arr[0];

for(var i = 1; i  <  arr.length; i++){
    if(arr[i] < smallest){
        smallest = arr[i];
        position = i;
    }
}

console.log(position + 1>;
Copy The Code & Try With Live Editor

Input

x
+
cmd
3 8 0 7

Output

x
+
cmd
2
Advertisements

Demonstration


Previous
#1849 Beecrowd Online Judge Solution 1849 Dracarys! Solution in C, C++, Java, Js and Python
Next
#1864 Beecrowd Online Judge Solution 1864 Our Days Are Never Coming Back Solution in C++, Java, Js and Python