Cod sursa(job #1474012)

Utilizator boss_nr_ekDorinel Alex boss_nr_ek Data 20 august 2015 18:09:39
Problema Euro Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include<fstream>
using namespace std;
int main()
{ ifstream fin("euro.in");
ofstream fout("euro.out");
    int n,t,i,x;
    long long int s=0,lei=0;
    fin>>n>>t;
    for(i=1;i<=n;i++){ fin>>x;
        s=s+x;
        if(s<0){
            lei=lei+s*i-t;
            s=0;


        } }
    lei=lei+s*n-t;
    fout<<lei;
   fin.close();
   fout.close();

    return 0;
}