提交时间:2024-05-05 09:20:45
运行 ID: 145468
#include<iostream> #include<algorithm> using namespace std; const int N = 110, M = 25010; int t, n, a[N], b[M], cnt = 0; int main(){ cin >> t; while(t--){ for(int i = 0; i < M; i++) b[i] = true; b[0] = cnt = 0; cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); for(int i = 0; i < n; i++){ if(b[a[i]]){ for(int j = 0; j < M-a[i]; j++){ if(!b[j]) b[j+a[i]] = false; } cnt++; } // for(int j = 10; j <= 25; j++) cout << b[j] << ' '; // cout << endl; } cout << cnt << endl; } return 0; }