-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path2070.cpp
More file actions
26 lines (26 loc) · 747 Bytes
/
2070.cpp
File metadata and controls
26 lines (26 loc) · 747 Bytes
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
class Solution {
public:
vector<int> maximumBeauty(vector<vector<int>>& items, vector<int>& queries) {
vector<pair<int, int>> Q;
int n = queries.size();
int m = items.size();
for (int i = 0; i < n; ++i) {
Q.push_back({queries[i], i});
}
sort(items.begin(), items.end());
sort(Q.begin(), Q.end());
set<int> st;
int index = 0;
vector<int> res(n, 0);
for (auto& q : Q) {
while (index < m && items[index][0] <= q.first) {
st.insert(items[index][1]);
index++;
}
if (!st.empty()) {
res[q.second] = *st.rbegin();
}
}
return res;
}
};