CopyRight

If you feel that any content has violated the copy-Right law please be free to mail me.
I will take suitable action.
Thanks
Showing posts with label Codechef. Show all posts
Showing posts with label Codechef. Show all posts

Thursday, 6 November 2014

Codechef , Topcoder - Never Miss a contest

 Codechef , Topcoder - Never Miss a contest 


Ever felt you have a bad memory and tend to forget things way to Fast. Specially if you are a geek and you have lots of stuff to do, you tend to miss out on coding contest on various online sites and that affects your ranking.

Here is simple yet very effective way to get yourself reminders , be it seconds before the contest start or weeks.

So the steps are as follows.

Step 1:
Add the calenders of various online judges.


HackerRank : Hackerrank
Top Coder : Topcoder
CodeForces : CodeForces
Code Chef : Codechef


Step 2:In the calendar list on the left, click the down-arrow button next to the appropriate calendar [in other calender ], then select Edit notifications.





Step 3:
In the Event Notifications section, select Add a Notification method. Then from the drop-down menu and enter the corresponding reminder time (between five minutes and four weeks).

You can select SMS, Pop up or Email. I generally prefer Sms.

If you'd like to add additional default reminders, simply click Add a Notification.



Step 4:Save

Thursday, 5 December 2013

Using Basic Vectors


VECTORS [STL :C++]

Want to sort an array of numbers but failing to choose a perfect sorting algorithm for the same looks cumbersome ? Want to optimize your solutions on sites like Codechef , HackerRank ? 
Then my friend C++ has the answer for you stored in it's STL library. 
STL library contains Vectors Container which is just like an array but with better functionalities. I have commented in the code the syntax and declaration of vector for easy understanding.

Question :
Given the list of numbers, you are to sort them in non decreasing order.

Input

t – the number of numbers in list, then t lines follow [t <= 10^6].

Each line contains one integer: N [0 <= N <= 10^6]

Output

Output given numbers in non decreasing order.

Example

Input:
5
5
3
6
7
1
Output:
1
3
5
6
7

Answer : 
 #include <iostream>  
 #include <vector>  //for vector  
 #include <algorithm> //for sort  
 #include <stdio.h>  
 using namespace std;  
 int main()  
 {  
   long int t,i,temp;  
   vector<long int> v;      //Creating a Vector v  
   scanf("%ld",&t);  
   for(i=0;i<t;i++)  
   {  
     scanf("%ld",&temp);  
     v.push_back(temp);    //adding the element at the end of the vector  
   }  
   sort(v.begin(),v.end());    //the function "sort" is defined in <algorithm.h>  
                    //It takes parameters from the vector as to range which it has to sort  
   for(i=0;i<t;i++)  
   {  
     printf("%ld\n",v[i]);  
   }  
   return 0;  
 }