Description: Simple question
#include <iostream>using namespacestd;intMain () {intI, J, a[ +], N, Count =0; CIN>>N; for(i =0; I < n; i++) {cin>>A[i]; } for(i =1; I < n1; i++) { if(a[i-1] <A[i]) { if(A[i] > a[i +1]) {count++; } } Else { if(A[i] < A[i +1]) Count++; }} cout<< count<<Endl; return 0;}
Question number: |
201604-1 |
Question Name: |
Vertex count |
Time limit: |
1.0s |
Memory Limit: |
256.0MB |
Problem Description: |
The problem description given n integers represents the sales of a store for a continuous n-day. If sales were to grow before the end of the day, and sales were reduced in the next day, the day would be a fold, in turn, the day would be a fold if the previous sales had decreased and then the sales grew. The rest of the day is not a folding point. For example, the 3rd and 6th days are vertices.
Given n integers a1, a2, ..., an represents sales volume, please calculate how many vertices are in total these days. In order to reduce ambiguity, the data we have given guarantees that the sales of two consecutive days in this N day are always different, namely Ai-1≠ai. Note that if the two days are not contiguous, the sales volume may be the same. Input format the first line of input contains an integer n. The second line contains n integers, separated by spaces, representing A1, A2, ..., an. Output format outputs an integer that represents the number of vertices that appear. Sample Input 7 5 4 1 2 3 6 4 Sample Output 2 evaluation use case scale and convention all evaluation cases meet: 1≤n≤1000, the daily sales volume is not more than 10000 non-negative integers. |
CCF Certification Exam-vertex count