Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
193906 | luckypet | 和谐俱乐部 | C++ | 解答错误 | 10 | 0 MS | 244 KB | 984 | 2025-05-27 14:57:16 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Member { int a, b; bool operator<(const Member& other) const { if (a != other.a) return a < other.a; return b > other.b; // 关键修正:相同a时按b降序排列 } }; int main() { int N; cin >> N; vector<Member> members(N); for (int i = 0; i < N; ++i) { cin >> members[i].a >> members[i].b; } // 按a升序,b降序排序 sort(members.begin(), members.end()); // 查找b的最长严格递减子序列 vector<int> tails; for (const auto& m : members) { // 找到第一个小于m.b的位置 auto it = lower_bound(tails.begin(), tails.end(), m.b, greater<int>()); if (it == tails.end()) { tails.push_back(m.b); } else { *it = m.b; } } cout << tails.size() << endl; return 0; }