zoukankan      html  css  js  c++  java
  • 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[]) {;}
  • 相关阅读:
    C语言01
    C++面试总结更新
    Python网络爬虫与信息提取02
    Self-Driving Car 01
    Python网络爬虫与信息提取01
    Python-03
    Shell
    Python-05
    Python-04
    Python-02
  • 原文地址:https://www.cnblogs.com/ZlycerQan/p/7367487.html
Copyright © 2011-2022 走看看