#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 time | Memory | Grader output |
|---|
| Fetching results... |