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 <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <cassert>
#include <stack>
#include <bitset>
#define mkp make_pair
#define err cout<<"err"<<endl
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<<res<<endl;
}

void work()
{
    
}

void release()
{
    
}

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

 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值