-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva11003.cpp
78 lines (50 loc) · 976 Bytes
/
uva11003.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <cstdio>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std
int grade(vector<int> weight, vector<int> load)
{
vector<int> LIS;
LIS.resize(v.size());
vector<int> capacity;
capacity.resize(v.size());
int len = 1;
LIS[0] = 1;
capacity[0] = load[0];
for(int i = 1; i < weight.size(); i++)
{
LIS[i] = 1;
capacity[i] = 0;
for(int j = 0; j < i; j++)
{
//daca se poate extinde secventa de lungime maxima
if(capacity[j] > weight[i] && max(capacity[j] - weight[i], capacity[j]) > capacity[i])
{
LIS[i] = max(LIS[i], 1 + LIS[j]);
capacity[i] = max(capacity
}
if(LIS[i] > len)
len = LIS[i];
}
return len;
}
int main()
{
int n;
int w, l;
vector<int> weight;
vector<int> load;
while(scanf("%d", &n))
{
if(n == 0)
break;
scanf("%d", &w);
weight.push_back(w);
scanf("%d", &l);
load.push_back(l);
}
return 0;
}