#include <iostream> #include <vector> using namespace std; int find(int index, int k) { int cur_res = 0; while ((k+1)*cur_res < index) cur_res++; return cur_res; } int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int res = 0; int k, m; cin >> k >> m; vector<int> num(30, -1); for (int j = 0; j < m; j++) { int temp; cin >> temp; num[temp-1] = 1; res++; int n = 0; while (n<=k) { if (temp -1 - n >= 0 && num[temp-1 - n] == -1) num[temp -1 - n] = 0; if (temp -1 + n <= 29 && num[temp-1 + n] == -1) num[temp -1 + n] = 0; n++; } } int n = 0; while (n < 30) { int index = 0; while (n<30 && num[n] == -1) { index++; n++; } int cur_res = find(index, k); res += cur_res; while (n < 30 && num[n] != -1) n++; } cout << res << endl; } system("pause"); return 0; }
喝咖啡
内容版权声明:除非注明,否则皆为本站原创文章。