Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
730 B
3
Indexable
Never
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long gh, sk, kh;
    cin >> gh >> sk >> kh;
    long long sum = gh * 17 * 29 + sk * 29 + kh;
    int n;
    cin >> n;
    long long cur = 0;
    for (int i = 0; i < n; ++i) {
        long long g, s, k;
        cin >> g >> s >> k;
        cur += g * 17 * 29 + s * 29 + k;
    }
    if (cur > sum) {
        cout << "-1" << endl;
    } else {
        long long du = sum - cur;
        long long a = du / (17 * 29);
        du %= (17 * 29);
        long long b = du / 29;
        long long c = du % 29;
        cout << a << " " << b << " " << c << endl;
    }

    return 0;
}
Leave a Comment