Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// https://www.hackerrank.com/contests/simulacro-oia-4-1/challenges/problem-0-rope-folding
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n, l, c=0;
- cin>>n>>l;
- vector<bool> v (l+1);
- int pos;
- for (int i=0; i<n; i++)
- {
- cin>>pos;
- v[pos] = true;
- }
- for (float q=1; q<l; q+=(0.5))
- {
- int centro = 2*q, ini=centro/2, fin=centro/2;
- if ( centro%2 == 1 )
- ini++; ///cout<<q<<" : "<<ini<<" "<<fin<<endl;
- bool es = true;
- while ( ini>0 && fin<l )
- {
- ini--;
- fin++;
- if ( v[ini] != v[fin] )
- es = false;
- }
- if (es)
- c++;
- }
- cout<<c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement