Sum3Problem code: ENCODE13 |
All submissions for this problem are available.
You're given an array 'a' of N distinct integers. Let's consider a triple ( i, j, k ), 0 <= i < j < k <= N-1. The sum of corresponding elements is equal to a[i]+a[j]+a[k]. For all the possible sums you can get by choosing such a triple output its value and the number of triples that result in such a sum.
Input
The first line of input contains an integer N (3 <= N <= 20000). Each of the next N lines contain an integer a[i] (|a[i]| <= 10000).Output
Output each of the possible sums in increasing order with the number of triples that generate them. The format should be: s[i] : ways[i] (s[i] = value of the i-th sum, ways[i] = number of triples that generate it)Example
Input: 4 -1 2 3 4 Output: 4 : 1 5 : 1 6 : 1 9 : 1Constraints:
3 <= N <= 20000 |a[i]| <= 10000 for all i.
| Author: | encoded_admin |
| Date Added: | 23-02-2011 |
| Time Limit: | 3 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, C, C99 strict, CLOJ, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, ICON, JAR, JAVA, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PYTH, PYTH 3.1.2, RUBY, SCM guile, SCM qobi, ST, TCL |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions
