二次联通门 : 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[]) {;}

 

相关文章:

  • 2021-11-29
  • 2021-12-14
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-05
  • 2021-11-17
  • 2021-11-17
猜你喜欢
  • 2021-07-13
  • 2021-11-17
  • 2021-11-17
  • 2021-10-30
  • 2021-11-01
  • 2021-08-26
相关资源
相似解决方案