khanaleemullah's blog

By khanaleemullah, 13 years ago, In English

today i attended the codeforces division 2 169 and came across this question.. http://mirror.codeforces.com/contest/276/problem/C I saw most of the red and yellow coder used the logic..

for(int i=0;i<k;i++){ cin>>x1>>x2; arr[x1-1]++; arr[x2]--; } for(int i=0;i<n;i++) arr[i]+=arr[i-1];

I was really shocked and I am unable to understand how so many of people knew this technique.. Is this any standard algorihtm or something??..

  • Vote: I like it
  • +15
  • Vote: I do not like it

»
13 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

Well, it is called delta encoding.

»
13 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Second cycle starts from 0, but index i — 1 uses. Here's might be problems. I guess it better starts from 1.