提交记录 6875
提交时间 |
评测时间 |
2018-11-11 19:27:03 |
2020-08-01 00:52:18 |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100+7;
const int Maxa = 25000+7;
int T, n, m;
int a[Maxn];
bitset<Maxa> need, now;
int main()
{
scanf("%d", &T);
while(T--)
{
m = 0;
need.reset();
now.reset();
now.set(0);
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
{
scanf("%d", a+i);
need.set(a[i]);
}
sort(a+1, a+n+1);
for(int i = 1; i <= n; ++i)
{
if(!now[a[i]])
{
m++;
for(int j = 1; j*a[i] <= a[n]; ++j)
now |= now<<a[i];
if((now&need) == need) break;
}
}
printf("%d\n", m);
}
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 147.24 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #2 | 186.89 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #3 | 162.87 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #4 | 223.08 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #5 | 478.9 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #6 | 242.32 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #7 | 464.8 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #8 | 196.39 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #9 | 525.67 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #10 | 455.3 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #11 | 221.72 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #12 | 207.99 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #13 | 180.24 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #14 | 315.84 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #15 | 313.44 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #16 | 317.27 us | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #17 | 3.142 ms | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #18 | 3.08 ms | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #19 | 3.203 ms | 48 KB | Accepted | Score: 5 | 显示更多 |
Testcase #20 | 3.341 ms | 48 KB | Accepted | Score: 5 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:36:26 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠