Created
April 29, 2017 09:55
-
-
Save ch-hristov/91e498c972f92be28b3b6dffac457c2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdio.h> | |
#include <algorithm> | |
#include <vector> | |
#include <map> | |
#include <math.h> | |
using namespace std; | |
int arr[1000001]; | |
int main() { | |
int t; | |
scanf("%d",&t); | |
while(t--){ | |
int n,k,r; | |
scanf("%d%d%d",&n,&k,&r); | |
for(int i =0;i<n;i++) arr[i]=0; | |
for(int i = 0;i<k;i++){ | |
int z; | |
scanf("%d",&z); | |
arr[z-1]=1; | |
} | |
int total = 0; | |
for(int i = 0;i<n-r;i++){ | |
int c = 0; | |
for(int j = i;j<i+r;j++){ | |
if(arr[j]==1){ | |
c++; | |
} | |
} | |
int add = 2 - c; | |
if(add < 0) add = 0; | |
total += add; | |
if(add > 0){ | |
for(int z = i + (r-1);z >= i; z--){ | |
if(arr[z] == 0 && add > 0){ | |
add--; | |
arr[z]=1; | |
} | |
} | |
} | |
} | |
printf("%d",total); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment