hiho week 72 register

Ended

Participants:370

Verdict:Accepted
Score:100 / 100
Submitted:2015-11-16 14:06:01

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 <stdio.h>
#include <algorithm>
using namespace std;
int a[100005];
int n, m, h, r, i;
int sol()
{
    int result = 0, S = 0;
    for (i = 0; i < n; i++)
    {
        if (a[i] > r + S)
            break;
        else
        {
            if (S != 0 && a[i]-a[i-1] > m)
            {
                result += S;
                S = 0; i--;
            }
            else S++;
        }
    }
    result += S;
    if (result > h) result = h;
    return result;
}
int main()
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX