Sunday, July 13, 2014

Codeforces Round #109 (Div. 2), problem: (A) I_love_\%username\% solution

Codeforces Round #109 (Div. 2), problem: (A) I_love_\%username\%: http://codeforces.com/problemset/problem/155/A

Codeforces Round #109 (Div. 2), problem: (A) I_love_\%username\% editorial: http://codeforces.com/blog/entry/3969

Codeforces Round #109 (Div. 2), problem: (A) I_love_\%username\% solution: http://ideone.com/xv2k0g


#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int n, mi, ma, a, cnt=0;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &a);
        if(i==0) mi=ma=a;
        else {
            if(a<mi) mi=a, cnt++;
            else if(a>ma) ma=a, cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}

No comments:

Post a Comment