add: 220128-CN
This commit is contained in:
parent
ec86560952
commit
945c416f90
|
|
@ -0,0 +1,24 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
class Solution {
|
||||
public:
|
||||
static int numberOfWeakCharacters(std::vector<std::vector<int>>& properties) {
|
||||
std::sort(properties.begin(), properties.end(), [](const std::vector<int>& x, const std::vector<int>& y) {
|
||||
if (x[0] - y[0])
|
||||
return x[0] > y[0];
|
||||
return x[1] < y[1];
|
||||
});
|
||||
int ret = 0, max = -1;
|
||||
for (const auto& i : properties)
|
||||
if ((max = std::max(i[1], max)) > i[1])
|
||||
++ret;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::vector<std::vector<int>> args = {{1,1},{2,1},{2,2},{1,2}};
|
||||
std::cout << Solution::numberOfWeakCharacters(args);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -3,4 +3,4 @@ PROJECT(2201)
|
|||
|
||||
SET(CMAKE_CXX_STANDARD 23)
|
||||
|
||||
ADD_EXECUTABLE(2201 220127.cpp)
|
||||
ADD_EXECUTABLE(2201 220128-CN.cpp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue