Cod sursa(job #965224)
Utilizator | Data | 23 iunie 2013 19:35:42 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include <fstream>
using namespace std;
int n;
long long result;
int main()
{
ifstream f ("operatii.in");
int x, i, last = 0;
f>>n;
for (i=1; i<=n; i++)
{
f>>x;
if (x > last)
result += x-last;
last = x;
}
f.close();
ofstream g ("operatii.out");
g<<result<<"\n";
g.close();
return 0;
}