FelipeTRM
FelipeTRM
Reputation Top 5%
FelipeTRM martins
1 Snippet  (487th place)
Published
1 Channel
Created
1 Channel
Following
36 points  (782nd place)
Reputation
Junior Code Generator
Junior Publisher
Junior Trend Maker
Junior Popular Coder
Junior Autobiographer
Junior Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by FelipeTRM

public by FelipeTRM  17217  187  7  0

Codingame - Temperatures - C++

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
int main()
{
    int N,c; // the number of temperatures to analyse
    scanf("%d", &N);
    int number[N],ptemps,i=0,FLAG=0,mark;

    for(i=0;i<N;i++){
        scanf("%d",&number[i]);
       }

    sort(number,number+N);

    for(i=0;i<N;i++){
       if(number[i]>0)FLAG++;
       if(FLAG==1)mark=i;
    }

    if(N==0)printf("0");
    else if(-1*number[mark-1]<number[mark])printf("%d",number[mark-1]);
    else printf("%d",number[mark]);

}
;