Cod sursa(job #2177376)

Utilizator ivddabDabelea Ioana-Viviana ivddab Data 18 martie 2018 15:08:01
Problema Euro Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <fstream>

using namespace std;
ifstream f("euro.in");
ofstream g("euro.out");
long long n,t,s,p,i,x,total;
int main()
{
    f>>n>>t;
    s=0; p=0; total=0;
    for(i=1;i<=n;i++) {
        f>>x; s+=x;
        if(s<0){
            total+=(i*s-t);
          //  g<<(i*s-t)<<' '<<p<<' '<<i<<' '<<s<<'\n';
            s=0;
        }
    }
    if(s!=0) total+=((n-p)*s-t);
    g<<total<<'\n';
    return 0;
}