LibreOJ #6217. 扑克牌
二次联通门 : LibreOJ #6217. 扑克牌
/* LibreOJ #6217. 扑克牌 背包。。。。 回到家之后简直了。。。sb题想半天 */ #include <cstdio> #include <iostream> const int BUF = 10000020; char Buf[BUF], *buf = Buf; void read (int &now) { for (now = 0; !isdigit (*buf); ++ buf); for (; isdigit (*buf); now = now * 10 + *buf - '0', ++ buf); } #define Max 1000020 int f[Max]; inline int max (int a, int b) { return a > b ? a : b; } int Main () { fread (buf, 1, BUF, stdin); int N; read (N); register int i, j; int x, y; for (i = 1; i <= N; ++ i) { read (x), read (y); for (j = N; j >= x; -- j) f[j] = max (f[j], f[j - x] + y); } printf ("%d", f[N]); return 0; } int ZlycerQan = Main (); int main (int argc, char *argv[]) {;}
myj 吊打我Orz,xxy 捆起来打我Orz,myl 文化课上天Orz, lrh 姿势水平敲高Orz, hkd 特别胖Orz%%%,cys 智商感人Orz,syl zz专业Orz,我没有学上, 我们未来一片光明