Cod sursa(job #2334951)
Utilizator | Data | 3 februarie 2019 13:31:52 | |
---|---|---|---|
Problema | Euro | Scor | 25 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euro.in");
ofstream fout("euro.out");
int main()
{
int n,t,e,l,x;
fin >> n >> t;
e=0;l=0;
for(int i=1;i<n;i++)
{
fin >> x;
e+=x;
if(e<0){
l=l+e*i-t;
e=0;
}
}
fin >> x;
e+=x;
l=l+e*n-t;
fout << l;
return 0;
}