zoukankan      html  css  js  c++  java
  • 2020牛客寒假算法基础集训营1 I-nico和niconiconi

     1 #include <bits/stdc++.h>
     2 #define dbg(x) cout << #x << "=" << x << endl
     3 
     4 using namespace std;
     5 typedef long long LL;
     6 const int maxn = 3e5 + 7;
     7 
     8 LL f[maxn];
     9 char ch[maxn];
    10 
    11 namespace _buff {
    12     const size_t BUFF = 1 << 19;
    13     char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
    14     char getc() {
    15         if (ib == ie) {
    16             ib = ibuf;
    17             ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    18         }
    19         return ib == ie ? -1 : *ib++;
    20     }
    21 }
    22 
    23 int read() {
    24     using namespace _buff;
    25     int ret = 0;
    26     bool pos = true;
    27     char c = getc();
    28     for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    29         assert(~c);
    30     }
    31     if (c == '-') {
    32         pos = false;
    33         c = getc();
    34     }
    35     for (; c >= '0' && c <= '9'; c = getc()) {
    36         ret = (ret << 3) + (ret << 1) + (c ^ 48);
    37     }
    38     return pos ? ret : -ret;
    39 }
    40 
    41 int main()
    42 {
    43     int n,a,b,c;
    44     scanf("%d %d %d %d
    ",&n,&a,&b,&c);
    45     scanf("%s",ch+1);
    46     for(int i = 0; i <= n; ++i) {
    47         if(i > 0) f[i] = f[i-1];
    48         if(i >= 4 && ch[i-3] == 'n' && ch[i-2] == 'i' && ch[i-1] == 'c' && ch[i] == 'o') {
    49             f[i] = max(f[i], f[i-3] + a);
    50         }
    51         if(i >= 6 && ch[i-5] == 'n' && ch[i-4] == 'i' && ch[i-3] == 'c' && ch[i-2] == 'o' && ch[i-1] == 'n' && ch[i] == 'i') {
    52             f[i] = max(f[i], f[i-5] + b);
    53         }
    54         if(i >= 10 && ch[i-9] == 'n' && ch[i-8] == 'i' && ch[i-7] == 'c' && ch[i-6] == 'o' && ch[i-5] == 'n' && ch[i-4] == 'i' && ch[i-3] == 'c' && ch[i-2] == 'o' && ch[i-1] == 'n' && ch[i] == 'i') {
    55             f[i] = max(f[i], f[i-9] + c);
    56         }
    57     }
    58     cout << f[n] << endl;
    59     return 0;
    60 }
    View Code
  • 相关阅读:
    Spring MVC Ajax 嵌套表单数据的提交
    Spring MVC 过滤静态资源访问
    Spring MVC 页面跳转时传递参数
    IDEA Maven 三层架构 2、运行 springMVC
    IDEA Maven 三层架构 1、基本的Archetype 搭建
    EasyUI DataGrid 基于 Ajax 自定义取值(loadData)
    Spring MVC Ajax 复杂参数的批量传递
    Mybatis Sql片段的应用
    在 Tomcat 8 部署多端口项目
    自动升级的设计思路与实现
  • 原文地址:https://www.cnblogs.com/orangeko/p/12261939.html
Copyright © 2011-2022 走看看