📄 1065.cpp
字号:
#include <iostream>#include <algorithm>#define BUFSIZE 10240using namespace std;struct Stick{ int l, w; bool in;};Stick sticks[BUFSIZE];bool compare(const Stick &x, const Stick &y);intmain(int argc, char *argv[]){ int t; cin >> t; int n; while (--t >= 0) { cin >> n; for (int i = 0; i < n; ++i) { cin >> sticks[i].l >> sticks[i].w; sticks[i].in = false; } sort(sticks, sticks + n, compare); int count = 0; int i = 0; while (i != n) { if (!sticks[i].in) { ++count; int j = i, k = i; while (j != n) { if (!sticks[j].in && sticks[k].l <= sticks[j].l && sticks[k].w <= sticks[j].w) { k = j; sticks[j++].in = true; } else ++j; } } else ++i; } cout << count << endl; } return 0;}boolcompare(const Stick &x, const Stick &y){ if (x.l != y.l) return x.l < y.l; return x.w < y.w;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -