Practice for Microsoft 2015 Online Test register

Ended

Participants:1406

Verdict:Time Limit Exceeded
Score:75 / 100
Submitted:2014-10-18 13:06:00

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
class pro
{
public:
    int need;
    int value;
};
int max_value(vector<pro> &object, int max_sum, int k)
{
    if(k>=(object.size()-1))
    {
        if(object[k].need<=max_sum)
        {
            return object[k].value;
        }
        else
        {
            return 0;
        }
    }
    if(object[k].need<=max_sum)
    {
        return max(object[k].value + max_value(object, max_sum-object[k].need, k+1), max_value(object, max_sum, k+1));
    }
    else
    {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX