hiho week 36 register

Ended

Participants:242

Verdict:Accepted
Score:100 / 100
Submitted:2015-03-09 09:59:00

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <cstdio>
#define N 1000000
int arr[N];
int main()
{
    int n, v, i, pos = -1, cnt = 0;
    scanf("%d%d", &n, &v);
    for(i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        if(arr[i] == v) {
            pos = i;
        }
    }
    if(pos == -1){
        printf("-1");
    }
    else {
        for(i = 0; i < n; i++) {
            if(arr[i] <= v)
                cnt++;
        }
        printf("%d", cnt);
    }
    
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX