View Code of Problem 6

#include <bits/stdc++.h>
using namespace std;
int main() {
    int T, n, l, r, a, b, c = 0, d;
    scanf("%d", &T);
    for (int i = 0; i < T; i++) {
        scanf("%d", &n);
        for (int j = 0; j < n; j++) {
            scanf("%d %d", &a, &b);
            c += (b  - a);
            d = b - a;
        }
        if(d * n != c)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 6