1: #include<vector>
2: using namespace std;
3:
4: class PiecewiseLinearFunctionDiv2
5: {
6: public:
7: vector <int> countSolutions(vector <int> Y, vector <int> query)
8: {
9: vector<int> result;
10: for(int i =0; i< query.size(); i++)
11: {
12: int searchNum = query[i];
13: int start = 0;
14: int solution=0;
15: if(searchNum == Y[start]) solution++;
16: for(int j =1; j< Y.size(); j++)
17: {
18: if(max(Y[start], Y[j]) > searchNum && min( Y[start], Y[j]) < searchNum)
19: {
20: solution++;
21: }
22: if(searchNum == Y[j])
23: {
24: if(searchNum == Y[start])
25: {
26: solution =-1;
27: break;
28: }
29: solution++;
30: //j++;
31: }
32: start = j;
33: }
34:
35: result.push_back(solution);
36: }
37: return result;
38: }
39: };