Saleh127

Untitled

May 7th, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6. bool solution[10000]={false};
  7. ll n,a[100000],c=0,d,e,f,i,j,k,l;
  8. cin>>n>>d;
  9. for(i=1;i<=n;i++)
  10. {
  11. cin>>a[i];
  12. }
  13. for(i=1;i<=n;i++)
  14. {
  15. for(j=i+1;j<=n;j++)
  16. {
  17. if(abs(i - d) == abs(j - d) && a[i] != a[j])
  18. {
  19. solution[i]=solution[j]=true;
  20. }
  21. }
  22. }
  23. for(k=1;k<=n;k++)
  24. {
  25. if(a[k]==1 && solution[k]==false)
  26. {
  27. c++;
  28. }
  29. }
  30. printf("%lld\n",c);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment