Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
417 B
0
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
long long a[1000],b[1000];
int main()
{
    int m;
    cin >> m;
    for (int f=0; f<m; f++)
    {
        cin >> a[f];
        cin >> b[f];
    }
    long long sum=a[0]+b[0];
    for (int f=1; f<m; f++)
    {
        if (sum<=a[f])
        {
            sum=a[f]+b[f];
        }
        else sum+=b[f];
    }
    cout << sum;


    return 0;
}
Leave a Comment