做网站php语言用什么工具,第一活动线报网,wordpress 网店,清远建网站的公司传送门 文章目录题意#xff1a;思路#xff1a;题意#xff1a;
思路#xff1a;
排序方式跟easyeasyeasy版本的一样#xff0c;但是hardhardhard版本是输出最多能选多少#xff0c;所以我们对b0b0b0的情况不能直接贪心的来选了#xff0c;考虑用dpdpdp来…传送门 文章目录题意思路题意
思路
排序方式跟easyeasyeasy版本的一样但是hardhardhard版本是输出最多能选多少所以我们对b0b0b0的情况不能直接贪心的来选了考虑用dpdpdp来解决。
设f[i][j]f[i][j]f[i][j]表示当前选了前iii个任务能力值为jjj的时候选的最多任务数。
转移的话比较简单按照背包来写就好但是转移的顺序不能改变也就是说我们需要提前按照aibia_ib_iaibi排序之后才能进行dpdpdp因为先选哪个显然是有影响的排序保证了先选的一定比后面选的更优。
// Problem: F1. Complete the Projects (easy version)
// Contest: Codeforces - Codeforces Round #579 (Div. 3)
// URL: https://codeforces.com/problemset/problem/1203/F1
// Memory Limit: 256 MB
// Time Limit: 2000 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 N1000010,mod1e97,INF0x3f3f3f3f;
const double eps1e-6;LL n,m;
int f[110][60011];
struct Node {int a,b;
};
vectorNodev1,v2;bool cmp1(Node a,Node b) {return a.ab.a;
}bool cmp2(Node a,Node b) {return a.aa.bb.ab.b;
}int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);scanf(%lld%lld,n,m);for(int i1;in;i) {int a,b; scanf(%d%d,a,b);if(b0) v1.pb({a,b});else v2.pb({a,b});}sort(v1.begin(),v1.end(),cmp1);sort(v2.begin(),v2.end(),cmp2);int cnt0;for(auto x:v1) {if(mx.a) mx.b,cnt;else break;}for(int i1;iv2.size();i) {int av2[i-1].a,bv2[i-1].b;for(int j0;jm;j) f[i][j]f[i-1][j];for(int j0;jm;j) {if(jb0ja) f[i][jb]max(f[i][jb],f[i-1][j]1);}}int ans0;for(int i0;im;i) ansmax(ans,f[v2.size()][i]);printf(%d\n,anscnt);return 0;
}
/**/