Hiho Interview Problems 2 register

Ended

Participants:465

Verdict:Accepted
Submitted:2014-09-14 13:57:09

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
29
30
31
#include<iostream>
#include<numeric>
#include<vector>
using namespace std;
const int MAX_VAL = 100;
void Find_Max(vector<int> ForgetDay, int M,int N){
    int max = 0;
    if (M >= N){
        max= MAX_VAL;
    }
    else{
        vector<int>::iterator it_first = ForgetDay.begin();
        vector<int>::iterator it_second = it_first + M+1;
        max =*it_first-1;
        for (; it_second != ForgetDay.end();it_first++,it_second++){
            max = max > (*it_second - *it_first-1) ? max : (*it_second - *it_first-1);
            vector<int>::iterator it_diff1 = it_second;
            vector<int>::iterator it_diff2 = it_second+1;
            for (; it_diff2 != ForgetDay.end(); it_diff2++, it_diff1++){
                max = max > (*it_diff2 - *it_diff1-1) ? max : (*it_diff2 - *it_diff1-1);
            }
        }
    }
    cout << max << endl;
}
int main(int argc, char*argv[]){
    int T, N, M;
    cin >> T;
    for (int i = 0; i < T; i++){
        cin >> N >> M;
        vector<int> ForgetDay(N);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX