diff --git a/2201/220128-CN.cpp b/2201/220128-CN.cpp new file mode 100644 index 0000000..d8c7533 --- /dev/null +++ b/2201/220128-CN.cpp @@ -0,0 +1,24 @@ +#include +#include + +class Solution { +public: + static int numberOfWeakCharacters(std::vector>& properties) { + std::sort(properties.begin(), properties.end(), [](const std::vector& x, const std::vector& 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> args = {{1,1},{2,1},{2,2},{1,2}}; + std::cout << Solution::numberOfWeakCharacters(args); + return 0; +} diff --git a/2201/CMakeLists.txt b/2201/CMakeLists.txt index b773bae..8431c7a 100644 --- a/2201/CMakeLists.txt +++ b/2201/CMakeLists.txt @@ -3,4 +3,4 @@ PROJECT(2201) SET(CMAKE_CXX_STANDARD 23) -ADD_EXECUTABLE(2201 220127.cpp) +ADD_EXECUTABLE(2201 220128-CN.cpp)