View Code of Problem 6

#include <iostream>
#include "vector"

using namespace std;

/**
 * kkmd66 四刷
 * @return
 */

int main() {

    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;

        //存储
        vector<vector<int>> vector(n);
        for (int i = 0; i < n; ++i) {
            int l, r;
            cin >> l >> r;
            vector[i].push_back(l);
            vector[i].push_back(r);
        }

        //最小步长
        int min_step = vector[0][1] - vector[0][0];
        for (int i = 0; i < vector.size(); ++i) {
            if (vector[i][1] - vector[i][0] > min_step)
                min_step = vector[i][1] - vector[i][0];
        }

        //判断
        bool flag = true;
        for (int i = 0; i < vector.size() - 1; ++i) {
            if (vector[i][0] + min_step > vector[i + 1][0]) {
                flag = false;
                break;
            }
        }

        //输出
        if (flag)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;

}

Double click to view unformatted code.


Back to problem 6