Submission #1301078

#TimeUsernameProblemLanguageResultExecution timeMemory
1301078tabTuna (COCI17_tuna)C++20
50 / 50
1 ms580 KiB
#include "bits/stdc++.h"
using namespace std;
#define intt long long
#define fi first
#define se second

const intt mxN = 1e5+1;
const intt LG = 20;
const intt inf = 1e18;  

intt n, x;

void _() {
    cin >> n >> x;
    intt ans = 0;
    for(intt i = 0; i < n; i++) {
        intt a, b;
        cin >> a >> b;
        if(abs(a - b) <= x) {
            ans += max(a, b);
        } else {
            intt c; cin >> c;
            ans += c;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    cout.tie(NULL);

    // freopen("checklist.in", "r", stdin);
    // freopen("checklist.out", "w", stdout);

    intt t = 1, buu = 1;
    // cin >> t;
    while(t--){
        // cout << "Case #" << buu++ << ": ";
        _();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...