医疗行业网站怎么做,网站反链和外链的区别,wordpress侧边小图标联系方式,东莞建设企业网站传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a; 思路#xff1a;
我们可以假设有两个桶#xff0c;让后向里面放数#xff0c;可以发现#xff0c;如果向其中放入了aia_iai#xff0c;那么紧跟在他后面的所有aia_iai的数都必须跟在ai…传送门
文章目录题意思路题意 思路
我们可以假设有两个桶让后向里面放数可以发现如果向其中放入了aia_iai那么紧跟在他后面的所有aia_iai的数都必须跟在aia_iai后面放在一个桶中所以我们可以根据这个分成若干段我们可以任意安排这些段使其放在两个桶中的任意一个如果最终能使两个桶的个数都为nnn那么就是可以的。 这个问题可以用可行性背包解决将段看成物品容量为nnn即可。
// Problem: D. Unmerge
// Contest: Codeforces - Codeforces Round #658 (Div. 2)
// URL: https://codeforces.com/contest/1382/problem/D
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)//#pragma GCC optimize(Ofast,no-stack-protector,unroll-loops,fast-math)
//#pragma GCC target(sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tunenative)
//#pragma GCC optimize(2)
#includecstdio
#includeiostream
#includestring
#includecstring
#includemap
#includecmath
#includecctype
#includevector
#includeset
#includequeue
#includealgorithm
#includesstream
#includectime
#includecstdlib
#includerandom
#includecassert
#define X first
#define Y second
#define L (u1)
#define R (u1|1)
#define pb push_back
#define mk make_pair
#define Mid ((tr[u].ltr[u].r)1)
#define Len(u) (tr[u].r-tr[u].l1)
#define random(a,b) ((a)rand()%((b)-(a)1))
#define db puts(---)
using namespace std;//void rd_cre() { freopen(d://dp//data.txt,w,stdout); srand(time(NULL)); }
//void rd_ac() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//AC.txt,w,stdout); }
//void rd_wa() { freopen(d://dp//data.txt,r,stdin); freopen(d://dp//WA.txt,w,stdout); }typedef long long LL;
typedef unsigned long long ULL;
typedef pairint,int PII;const int N4010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;int n;
int p[N];
bool f[N];int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);int _; scanf(%d,_);while(_--) {scanf(%d,n);for(int i1;in*2;i) scanf(%d,p[i]);for(int i0;in;i) f[i]false;vectorintv;for(int i1;in*2;i) {int nowp[i];int cnt0;while(in*2p[i]now) cnt,i;i--;v.pb(cnt);}f[0]true;for(int i0;iv.size();i) {for(int jn;jv[i];j--)f[j]|f[j-v[i]];}if(f[n]) puts(YES);else puts(NO);}return 0;
}
/**/