Cod sursa(job #671280)
Utilizator | Data | 31 ianuarie 2012 08:34:55 | |
---|---|---|---|
Problema | Euro | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Lista lui wefgef | Marime | 0.28 kb |
#include <fstream>
using namespace std;
int tot,s,x,t,n,i;
int main()
{
ifstream f("euro.in");
ofstream g("euro.out");
f>>n>>t;
for(i=1;i<=n;i++)
{f>>x;
s+=x;
if(s<0)
{tot+=(s*i-t);
s=0;}
}
if(s)
tot+=(s*n-t);
g<<tot;
f.close();
g.close();
return 0;
}