c++ greedy faster than 100%
c++\n// \u5982\u679C\u7B49\u4E8E 2,\u4E24\u884C\u90FD\u4E3A 1\n// \u5982\u679C\u7B49\u4E8E1\uFF0C\u53D6\u503C\u5269\u4F59\u5927\u7684\u4E00\u884C\u6539\u4E3A1\n
```c++\n// \u5982\u679C\u7B49\u4E8E 2,\u4E24\u884C\u90FD\u4E3A 1\n// \u5982\u679C\u7B49\u4E8E1\uFF0C\u53D6\u503C\u5269\u4F59\u5927\u7684\u4E00\u884C\u6539\u4E3A1\nclass Solution {\npublic:\n    vector<vector<int>> reconstructMatrix(int upper, int lower, vector<int>& colsum) {\n\t\tint n = colsum.size();\n        vector<vector<int>> ret(2, vector<int>(n, 0));\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (colsum[i] == 2) {\n\t\t\t\tret[0][i] = 1;\n\t\t\t\tret[1][i] = 1;\n\t\t\t\t--upper;\n\t\t\t\t--lower;\n\t\t\t} else if (colsum[i] == 1) {\n\t\t\t\tif (lower > upper) {\n\t\t\t\t\tret[1][i] = 1;\n\t\t\t\t\t--lower;\n\t\t\t\t} else {\n\t\t\t\t\tret[0][i] = 1;\n\t\t\t\t\t--upper;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (upper != 0 || lower != 0) {\n\t\t\treturn vector<vector<int>>();\n\t\t}\n\t\t\n\t\treturn ret;\n    }\n};\n```
[]