0417总结

dp  点击打开链接

单调递增子序列   [二分法]    转移方程和边界条件点击打开链接

7
1 9 10 5 11 2 13
2
2 -1
样例输出
5
1

心急的C小加(题外)点击打开链接

3
5
4 9 5 2 2 1 3 5 1 4
3
2 2 1 1 2 2
3
1 3 2 2 3 1
样例输出
2
1
3

矩阵嵌套

1
10
1 2
2 4
5 8
6 10
7 9
3 1
5 8
12 10
9 7
2 2
样例输出
5

邮局    [中位数]点击打开链接

1
10 5
1 2 3 6 7 9 11 22 44 50
样例输出
9

子串和  [枚举]

1
5
1 2 -1 3 -2
样例输出
5

股票   [逆差]

4
947 267 359 771
7
669 735 322 794 397 565 181
样例输出
504
472

探寻宝藏 点击打开链接

传纸条(一)  双线程dp   点击打开链接 

1
3 3
0 3 9
2 8 5
5 7 0样例输出
34

子串和再续  使m个子串和最大点击打开链接

1
3 6
-1 4 -2 3 -2 4
样例输出
11

石子合并    区间dp点击打开链接


圆形操场

蚂蚁的难题(四)点击打开链接

#include
    
    
     
     
#include
     
     
      
      
int p[10001];
char str[10001];
int main()
{
    int m,max;
    scanf("%d",&m);
    while(m--)
    {
        int i,j,len;
        scanf("%s",str);
        len=strlen(str);
                p[0]=1;
                for(i=1,max=1;i
      
      
       
       =0;j--)
                    if(str[i]>str[j]&&p[i]
       
        
        
// lower_bound/upper_bound example
#include 
            
                 
            
            // std::cout
#include 
            
                
            
            // std::lower_bound, std::upper_bound, std::sort
#include 
            
                   
            
            // std::vector

int main () {
  int myints[] = {10,20,30,30,20,10,10,20};
  std::vector<int> v(myints,myints+8);           // 10 20 30 30 20 10 10 20

  std::sort (v.begin(), v.end());                // 10 10 10 20 20 20 30 30

  std::vector<int>::iterator low,up;
  low=std::lower_bound (v.begin(), v.end(), 20); //          ^
  up= std::upper_bound (v.begin(), v.end(), 20); //                   ^

  std::cout << "lower_bound at position " << (low- v.begin()) << '\n';
  std::cout << "upper_bound at position " << (up - v.begin()) << '\n';

  return 0;
}
template 
          
          
           
           
  ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val)
{
  ForwardIterator it;
  iterator_traits
           
           
            
            ::difference_type count, step;
  count = distance(first,last);
  while (count>0)
  {
    it = first; step=count/2; advance (it,step);
    if (*it
            
            

             
             #include
              
              
                #include 
               
                 using namespace std; const int MAX=100100; int num[MAX],top; int main() { int n,i,*p; while(scanf("%d",&n)!=EOF) { scanf("%d",&num[0]); top=1; for( i=1;i 
                 
                 #include 
                  
                    int a[100005]; int dp[100005]; int binarysearth(int x,int len) { int left=1,right,mid; right=len; mid=(left+right)/2; while(left<=right) { if(x>dp[mid]) { left=mid+1; } else if(x 
                   
                     len) len=j; } printf("%d\n",len); } return 0; } 
                    
                   
                 
// lower_bound/upper_bound example
#include 
                     
                          
                     
                     // std::cout
#include 
                     
                         
                     
                     // std::lower_bound, std::upper_bound, std::sort
#include 
                     
                            
                     
                     // std::vector

int main () {
  int myints[] = {10,20,30,30,20,10,10,20};
  std::vector<int> v(myints,myints+8);           // 10 20 30 30 20 10 10 20

  std::sort (v.begin(), v.end());                // 10 10 10 20 20 20 30 30

  std::vector<int>::iterator low,up;
  low=std::lower_bound (v.begin(), v.end(), 20); //          ^
  up= std::upper_bound (v.begin(), v.end(), 20); //                   ^

  std::cout << "lower_bound at position " << (low- v.begin()) << '\n';
  std::cout << "upper_bound at position " << (up - v.begin()) << '\n';

  return 0;
}
template 
                   
                   
                    
                    
  ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val)
{
  ForwardIterator it;
  iterator_traits
                    
                    
                     
                     ::difference_type count, step;
  count = distance(first,last);
  while (count>0)
  {
    it = first; step=count/2; advance (it,step);
    if (*it
                     
                     

                      
                      #include
                       
                       
                         #include 
                        
                          using namespace std; const int MAX=100100; int num[MAX],top; int main() { int n,i,*p; while(scanf("%d",&n)!=EOF) { scanf("%d",&num[0]); top=1; for( i=1;i 
                          
                          #include 
                           
                             int a[100005]; int dp[100005]; int binarysearth(int x,int len) { int left=1,right,mid; right=len; mid=(left+right)/2; while(left<=right) { if(x>dp[mid]) { left=mid+1; } else if(x 
                            
                              len) len=j; } printf("%d\n",len); } return 0; } 
                             
                            #include 
                          
                            #include 
                           
                             int p[10001]; char str[10001]; int main() { int m,max; scanf("%d",&m); while(m--) { int i,j,len; scanf("%s",str); len=strlen(str); p[0]=1; for(i=1,max=1;i 
                            
                              =0;j--) if(str[i]>str[j]&&p[i] 
                             
                               #include 
                              
                                //#include 
                               
                                 using namespace std; int main() { //freopen("1.txt","r",stdin); int n ; cin>>n; while(n--) { string str; int count=1; cin>>str; int a[200],p[200]; a[0]=-999; for (int i=0;i 
                                
                                  =0;j--) { if((int)str[i]>a[j]) { a[j+1]=str[i]; p[j+1]=i; if(j+1==count) count++; break; } } } for(int i=1;i 
                                 
                                   // std::cout #include 
                                  
                                    // std::lower_bound, std::upper_bound, std::sort #include 
                                   
                                     // std::vector int main () { int myints[] = {10,20,30,30,20,10,10,20}; std::vector 
                                    
                                      v(myints,myints+8); // 10 20 30 30 20 10 10 20 std::sort (v.begin(), v.end()); // 10 10 10 20 20 20 30 30 std::vector 
                                     
                                       ::iterator low,up; low=std::lower_bound (v.begin(), v.end(), 20); // ^ up= std::upper_bound (v.begin(), v.end(), 20); // ^ std::cout << "lower_bound at position " << (low- v.begin()) << '\n'; std::cout << "upper_bound at position " << (up - v.begin()) << '\n'; return 0; } lower_bound at position 3 upper_bound at position 6 template 
                                      
                                        ForwardIterator lower_bound (ForwardIterator first, ForwardIterator last, const T& val) { ForwardIterator it; iterator_traits 
                                       
                                         ::difference_type count, step; count = distance(first,last); while (count>0) { it = first; step=count/2; advance (it,step); if (*it 
                                        
                                          #include 
                                         
                                           using namespace std; const int MAX=100100; int num[MAX],top; int main() { int n,i,*p; while(scanf("%d",&n)!=EOF) { scanf("%d",&num[0]); top=1; for( i=1;i 
                                          
                                            int a[100005]; int dp[100005]; int binarysearth(int x,int len) { int left=1,right,mid; right=len; mid=(left+right)/2; while(left<=right) { if(x>dp[mid]) { left=mid+1; } else if(x 
                                           
                                             len) len=j; } printf("%d\n",len); } return 0; } #include 
                                            
                                              #include 
                                             
                                               //#include 
                                              
                                                using namespace std; int main() { //freopen("1.txt","r",stdin); int n ; cin>>n; while(n--) { string str; int count=1; cin>>str; int a[200],p[200]; a[0]=-999; for (int i=0;i 
                                               
                                                 =0;j--) { if((int)str[i]>a[j]) { a[j+1]=str[i]; p[j+1]=i; if(j+1==count) count++; break; } } } for(int i=1;i 
                                                 
                                                
                                               
                                              
                                             
                                            
                                           
                                          
                                         
                                        
                                       
                                      
                                     
                                    
                                   
                                  
                                 
                                
                               
                              
                             
                            
                           
                          
                         
                       
                     
                     
                    
                    
                   
                   

背包点击打开链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值