程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> hdu 5265 pog loves szh II

hdu 5265 pog loves szh II

編輯:關於C++

 

#include 
#include 
#include 
using namespace std;
const int maxn=100000+5;
int data[maxn];
int main()
{
    int m,p;
    while(scanf(%d%d,&m,&p)!=-1)
    {
        for(int i=0; idata[m-2])
            printf(%d
,data[m-1]+data[m-2]);
        else
        {
            int now=0;
            int ans=data[m-1]+data[m-2]-p;
            for(int i=m-1; i>=1; i--)
            {
                for(int j=now; jdata[j])
                    ans=max(data[i]+data[j],ans);
                    else
                    {
                        if(j>0)
                        now=j-1;
                        break;
                    }
                    if(ans==p-1)
                        break;
                }
                if(ans==p-1)
                        break;
            }
            printf(%d
,ans);
        }
    }
    return 0;
}
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved