zoukankan      html  css  js  c++  java
  • luogu3146 [USACO16OPEN]248

    细节被坑惨

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 const int maxn=1e6+5;
     4 const int INF=1e9+7;
     5 int n,ans,dp[305][305];
     6 template <class t>void red(t &x)
     7 {
     8     x=0;
     9     int w=1;
    10     char ch=getchar();
    11     while(ch<'0'||ch>'9')
    12     {
    13         if(ch=='-')
    14             w=-1;
    15         ch=getchar();
    16     }
    17     while(ch>='0'&&ch<='9')
    18     {
    19         x=(x<<3)+(x<<1)+ch-'0';
    20         ch=getchar();
    21     }
    22     x*=w;
    23 }
    24 void input()
    25 {
    26     freopen("input.txt","r",stdin);
    27 }
    28 void read()
    29 {
    30     red(n);
    31     for(int i=1;i<=n;++i)
    32         red(dp[i][i]); 
    33 }
    34 void work()
    35 {
    36     for(int i=1;i<=n;++i)
    37         for(int j=1;j+i<=n+1;++j)
    38         {
    39             int e=i+j-1;
    40             for(int k=j;k<e;++k)
    41                 if(dp[j][k]==dp[k+1][e]) 
    42                     dp[j][e]=max(dp[j][e],dp[j][k]+1);
    43                 ans=max(ans,dp[j][e]);
    44             //    else
    45             //        dp[j][e]=max(dp[j][e],max(dp[j][k],dp[k+1][e]));
    46         }
    47     printf("%d",ans);
    48 }
    49 int main()
    50 {
    51     //input();
    52     read();
    53     work();
    54     return 0;
    55 }
    View Code
  • 相关阅读:
    左边菜单导航
    css3实现轮播
    js-统计选项个数
    空间评论。回复。点赞功能
    简单的购物车功能
    字符串常用的几种方法
    React,js实现分页的案列
    python2的cgi程序
    开发环境和工具
    github入门
  • 原文地址:https://www.cnblogs.com/Achensy/p/10804490.html
Copyright © 2011-2022 走看看