codeforces 1159 B. Expansion coefficient of the array

题意:略。

我的解法与官方题解不一样。举例来看:1,2,3,4,5,6,7,8,9,10。先枚举长度,长度为10的时候只能是1和10的最小值除以9。长度为9时是1,10,2,9最小值除以8。长度为8时是1,8,2,9,3,10的最小值除以7。用优先队列维护就行。

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include <set>
#include 
#include 
#include 
#define mkp make_pair
#define err cout<<"err"<using namespace std;
const double EPS=1e-8;
typedef long long lon;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const lon SZ=300010,SSZ=SZ*SZ,APB=4,one=1;
const lon INF=0x3f3f3f3f,mod=1000000007;
lon n,arr[SZ];

void init()
{
    cin>>n;
    for(int i=1;i<=n;++i)cin>>arr[i];
    int res=INF;
    priority_queue<int,vector<int>,greater<int> > pq;
    for(int i=1,j=n,len=n-1;i<j;)
    {
        pq.push(arr[i]);
        if(i!=j)pq.push(arr[j]);
        res=min(res,pq.top()/len);
        ++i,--j,--len;
        if(pq.size()==n)break;
    }
    cout<endl;
}

void work()
{
    
}

void release()
{
    
}

int main()
{
    std::ios::sync_with_stdio(0);
    //freopen("d:\\1.txt","r",stdin);
    lon casenum;
    //cin>>casenum;
    //cout<//for(lon tim=1;tim<=casenum;++tim)
    //for(lon tim=1;cin>>n;++tim)
    {
        //cout<<"Case #"<
        init();
        work();
        release();
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/gaudar/p/11540146.html

你可能感兴趣的:(codeforces 1159 B. Expansion coefficient of the array)