#515. 「LibreOJ β Round #2」贪心只能过样例 (bitset)
题意:https://loj.ac/problem/515
考虑O(N^2S)的暴力(S是最终答案的上界,为1e6),就是暴力可行性DP
用bitset优化一下即可
code:
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
const int maxm=1e6+10;
int n;
int a[maxn],b[maxn];
bitset<maxm>f[2];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
f[0][0]=1;
for(int i=1;i<=n;i++)
{
int now=i&1;
f[now].reset();
for(int j=a[i];j<=b[i];j++)f[now]|=(f[now^1]<<(j*j));
}
printf("%d",f[n&1].count());
return 0;
}