Moving Intervals ZCO-2018

HELLO!
In this problem: PROBLEM

#include <bits/stdc++.h>

using namespace std;
#define ll long long
int t, k;
ll c, n;
ll a, b;
bool flag = 1;
int main() {
    cin >> t;
    while (t--) {
        cin >> c >> n >> k;
        if (k == 0) {
            vector < ll > col(c + 1, 0);
            for (int i = 0; i < n; ++i) {
                cin >> a >> b;
                if (flag == 0) {

                    break;
                }
                for (int j = a; j <= b; ++j) {

                    if (col[j] == 1) {
                        flag = 0;
                        break;
                    } else {
                        col[j] = 1;
                    }
                }
                flag = 1;
            }
            if (flag == 0) {
                cout << "Bad";
            } else {
                cout << "Good";
            }
            cout << "\n";
        } else {
            ll sum = 0;
            for (int i = 0; i < n; ++i) {
                cin >> a >> b;
                sum += b - a + 1;
                if (sum > c) {
                    flag = 0;
                    break;
                }
            }
            if (flag == 0) {
                cout << "Bad";
            } else {
                cout << "Good";
            }
            cout << "\n";

        }

    }

}

I have used appearance array for first, for second case that is k=1, i wasn’t able to think more and more about the solution so i just did what was obvious,
And…


I am getting this error
Along with 3 Right Task, I want to know How can i make it better?

Also i cant find the editorial Link for this can anyone post in here, even if it is unofficial

I think, this error is occuring due to large memory size occupied by array of size 1e9, as value of C can go upto 1e9 (described in question 1 ≤ C ≤ 10^9). Creating such large array consumes vast amount of memory.

Is there the editorial for thi problem