-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path1952.cc
49 lines (43 loc) · 1.17 KB
/
1952.cc
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
#include <iostream>
using namespace std;
int price[5000];
int maxbuy[5000];
int maxlen;
int main() {
int n;
cin >> n;
for(int i = 0; i < n; ++i) {
cin >> price[i];
maxbuy[i] = 1;
vector<int> v;
v.push_back(price[i]);
sequence[i].push_back(v);
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < i; ++j) {
if(price[i] < price[j]) {
if(maxbuy[j]+1 > maxbuy[i]) {
maxbuy[i] = maxbuy[j]+1;
if(maxbuy[i] > maxlen) maxlen = maxbuy[i];
}
}
}
for(int j = 0; j < i; ++j) {
if(maxbuy[j] == maxbuy[i]-1) {
for(int k = 0; k < sequence[j].size(); ++k) {
vector<int> v = sequence[j][k];
v.push_back(price[i]);
sequence[i].push_back(v);
++pattern[i];
}
}
}
}
int cnt = 0;
for(int i = 0; i < n; ++i) {
if(maxbuy[i] == maxlen) cnt += pattern[i];
//cout << price[i] << " " << maxbuy[i] << endl;
}
cout << maxlen << " " << cnt << endl;
return 0;
}