-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cipmylo.cpp
75 lines (63 loc) · 1.56 KB
/
Cipmylo.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
67
68
69
70
71
72
73
74
75
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
typedef pair<int,int> pii;
bool in_vec=false;
struct input_data{
ll byear;
ll eyear;
int virus;
ll total_game;
};
ll b_search(vector<ll> &vec, ll target){
ll l = 0, h = vec.size()-1;
ll m;
while(l <= h){
m = (l + h) / 2;
if(vec[m] == target){
//h = m - 1;
in_vec = true;
return m;
}else if(vec[m] > target){
h = m - 1;
}else{
l = m + 1;
}
}
return l;
}
int main(void){
fastio;
int n,m,s;
cin >> n >> m >> s;
vector<ll>games(n,0);
for(int i=0;i<n;i++){
cin >> games[i];
}
sort(games.begin(),games.end());
vector<input_data> testcase;
ll total_virus = 0;
for(int i=0;i<m;i++){
input_data tmp;
cin >> tmp.byear >> tmp.eyear >> tmp.virus;
ll idx1 = b_search(games, tmp.byear);
in_vec = false;
ll idx2 = b_search(games, tmp.eyear);
if(in_vec)idx2+=1;
tmp.total_game = idx2 - idx1;
total_virus+=tmp.total_game;
testcase.push_back(tmp);
in_vec = false;
}
ll ans=n-total_virus;
ll c[s+1];
memset(c,0,sizeof(c));
for(int i=0;i<m;i++){
for(int j=s;j-testcase[i].virus>=0;j--){
c[j] = max(c[j], c[j-testcase[i].virus]+testcase[i].total_game);
}
}
ans += c[s];
cout << ans;
}