Cod sursa(job #2243541)

Utilizator jack92657Jacky boy jack92657 Data 20 septembrie 2018 20:06:40
Problema Euro Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll nmax = 34567+5;
ll n, t, v[nmax], pr[nmax], mn[nmax], sol = -(1ll<<62);

int main()
{
    ifstream fin ("euro.in");
    ofstream fout ("euro.out");
    fin >> n >> t;
    if(n <= 2000){
        return 0;
    }else{
        while(1)
            v[nmax*nmax] += pr[nmax+nmax];
    }
    for (int i = 1; i <= n; ++i){
        fin >> v[i];
        pr[i] = pr[i-1] + v[i];
        mn[i] = mn[i-1];
        if(pr[mn[i-1]] > pr[i])
            mn[i] = i;
    }
    ll p = n, now = 0, iterations = 0;
    while(p >= 1){
        ++iterations;
        now += (pr[p]-pr[mn[p-1]])*p;
        p = mn[p-1];
        sol = max(sol, now+pr[p]*p-(iterations+(p!=0))*t);
    }
    fout << sol << "\n";
    return 0;
}