Submission #49827

# Submission time Handle Problem Language Result Execution time Memory
49827 2018-06-03T11:30:06 Z A_H_Ghaznavi Rasvjeta (COCI17_rasvjeta) C++14
50 / 50
4 ms 692 KB
// In the name of god
// A.H.Ghaznavi
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,k,lig[1010],x[1010],r,ans;
bool ligtf[1010];
int nomore(int z)
{
    if (z<=n)
        return z;
    else
        return n;
}
int no0(int z)
{
    if (z>=1)
        return z;
    else
        return 1;
}
int sagf (int z,int y)
{
    if (z%y==0)
        return z/y;
    else
        return z/y+1;
}
int main()
{
    cin>>n>>m>>k;
    for (int i=1;i<=m;i++)
    {
        cin>>lig[i];
        for (int i2=no0(lig[i]-k);i2<=nomore(lig[i]+k);i2++)
            ligtf[i2]=true;
    }
    for (int i=1;i<=n;i++)
    {
        if (!ligtf[i])
            x[r]++;
        else
            r++;
    }
    for (int i=0;i<=r;i++)
        ans+=sagf(x[i],k*2+1);
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 656 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 3 ms 656 KB Output is correct
9 Correct 3 ms 656 KB Output is correct
10 Correct 4 ms 692 KB Output is correct