Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- //n = number of pirates
- int n , aux, in, result=0;
- scanf("%d %d", &n, &in);
- aux =0; //1ª posicao sera usada como indice mais p frente
- int ar[n];
- int comp[n];
- ar[0] = in;
- //preenchendo o array com as desvantagens
- for(int j = 1; j < n; j++){
- scanf("%d", &ar[j]);
- }
- //comparando e salvando o de maior # de comparações
- for(int i = 1; i < n; i++){
- comp[aux]++;
- comp[i]++;
- if((ar[aux] > ar[i]) || (i == n-1)){
- if(comp[aux] > comp[result]){
- result = aux;
- }
- aux = i;
- }
- }
- printf("%d \n", result+1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement