codefoces 116A solution in c/c++

// 116A.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
using namespace std;

int main()
{
int n,anis[100];
int a, b,c=0,d,e;
int i = 0;
int temp;
cin >> n;
e = n;
while (n--)
{
cin >> a >> b;
c =c+ b-a;
anis[i] = c;
i++;
}
d = anis[0];
for (int j = 1;j < e;j++)
{
if (d < anis[j])
{
temp = d;
d = anis[j];
anis[j] = temp;
}
}
cout << d;
}


Comments

Popular posts from this blog

codeforces 472A problem solution in simple c/c++

codeforces 339A solution in c/c++

codeforces 520A problem solution in c/c++