Pieck's blog

By Pieck, history, 3 years ago, In English

What are you thoughts on CodeChef?

I recently reached 6 star on CodeChef (CC) and it made me think, why so many of the users which are 5 or 6 star on CC are less than 1700 on Codeforces (CF). For me, one of the reasons is that many of the CF questions don't need you to use fancy DSAs, they rely more on problem solving and using basic techniques while CC has some form of DSA question as you advance to the 3rd or 4th question even in Div 2 rounds. Also the number of people participating in CF is way more than that at CC which hits you like a rock even if you solve it 2 minutes too late.

For Chess Fans

What are your thoughts about this?

Full text and comments »

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

By Pieck, history, 3 years ago, In English

CLOSED

Can someone please explain me why this piece of code is taking around 25 secs to run, though the complexity is O(N^2log(N)) where N<=5000.

int n = 5000;
for(int i=0; i<n; i++) {
    set<int> s;
    for(int j=n; j>=1; j--) s.insert(j);
}

Full text and comments »

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

By Pieck, history, 3 years ago, In English

CLOSED

Recently I encountered a problem in one of the coding rounds that I attended and as of yet I am unable to solve it, or even find a direction in which to tackle this. I've tried using greedy or dp but could not find any solution. I don't know what the difficulty of the problem might be, but I thought of sharing it anyway. Any help would be appreciated.

Problem Statement:
You are standing in an election for your college. To win the election you need to win maximum number of hostels out of N possible. Your friends come up with a strategy to help you win. According to them for a given hostel i (1<=i<=N) the campaigning in that hostel starts from day a[i]. You are given L (the end date for campaigning). To win in a particular hostel i, you can start campaigning in that hostel from a[i] onward (a[i] inclusive), but you need to campaign for at least b[i] days straight (without any breaks) to win in that hostel, such that your last campaigning day doesn't exceed L.

Constraints:
1<=T<=1000
1<=N<=1000, 1<=L<=1000
1<=a[i], b[i]<=1000

Input:
T (testcases)
N L
a[1] b[1]
a[2] b[2]
...
...
a[N] b[N]

Output:
X (Maximum hostels you could win)

Sample Testcase:
Input:
1
2 10
2 2
2 7
Output:
2
Explanation:
You campaign from day 2 to day 8 in hostel 2 and from day 9 to day 10 in hostel 1.

Full text and comments »

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