Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main () {
- int number;
- cin >> number;
- int sum = 0;
- int currentSum = 0;
- int diff = 0;
- int maxDiff = 0;
- for(int i = 1; i <= number; i++) {
- int num1, num2;
- cin >> num1 >> num2;
- if (i == 1) {
- sum = num1 + num2;
- }
- if (i > 1) {
- currentSum = num1 + num2;
- if (currentSum != sum) {
- diff = currentSum - sum;
- currentSum = sum;
- }
- if (diff > maxDiff) {
- maxDiff = diff;
- }
- currentSum = 0;
- diff = 0;
- }
- }
- if (maxDiff != 0) {
- cout << "No, maxdiff=" << maxDiff << endl;
- } else {
- cout << "Yes, value=" << sum << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment