0% found this document useful (0 votes)
36 views3 pages

Problem - AA: Mitra1 Challenges Submissions Leaderboard

The document describes a programming problem that provides a Python solution for calculating the number of combinations of selecting items from a list that exceeds the time limit. The task is to write a more efficient program that solves the same problem and returns the correct output within the time limit. Sample inputs and outputs are provided to test the solution.

Uploaded by

Oreochoco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Problem - AA: Mitra1 Challenges Submissions Leaderboard

The document describes a programming problem that provides a Python solution for calculating the number of combinations of selecting items from a list that exceeds the time limit. The task is to write a more efficient program that solves the same problem and returns the correct output within the time limit. Sample inputs and outputs are provided to test the solution.

Uploaded by

Oreochoco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Mitra1 2

Challenges
Submissions
Leaderboard
The contest is in progress. It ends about 2 hours from now.

Contests
IEEEXtreme Programming Competition 7.0

problem_AA

Problem
Submissions
Leaderboard
Discussions

In this problem, we give you a solution. Your only task is to make it more efficient,
so that you would not hit the time limit.
def o(s):
l=len(s)
return len(set([a+b+c
for a in s for b in s for c in s])
)==l*(l+1)*(l+2)//6
M=int(input())
N=3**M
i=1
s=M*[i]
while i:
if s[i]-N:
s[i]=s[i]+1
if o(s[:i+1]):
if i<M-1:
i=i+1
s[i]=s[i-1]
else:
N=s[-1]
else:
i=i-1
print(N)

So write a program which gives the same output as the following Python program, but
runs within the time limit.

Sample Input 1:
2

Sample Output 1:
2

Sample Input 2:
4

Sample Output 2:
12

You can assume that the input is a single number n in the range 1 < n < 11
Problem Author: IEEE
Suggest Edits
Emacs Normal Vim
Select Language:

save code

#include <stdio.h>

2
#include <string.h>

#include <math.h>

4
#include <stdlib.h>

5
6
int main() {

7
8
/* Enter your code here. Read input from STDIN. Print output to
STDOUT */

9
return 0;

10
}

11
Line: 1 Col: 1 Count: 190
Use a custom test case
This is a beta version. Join us on IRC at #hackerrank on freenode for hugs or bugs.
Contest Calendar | Blog | Scoring | Environment | FAQ | About Us | Careers | Privacy Policy | Request a Feature

You might also like