제출 #597906

#제출 시각아이디문제언어결과실행 시간메모리
597906DevigoTuna (COCI17_tuna)C++14
50 / 50
1 ms324 KiB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair

const int siz = 0;
const int mod = 0;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int x; cin >> x;
	long long val = 0;
	while(n--) {
		int a, b; cin >> a >> b;
		int dif = abs(a-b);
		if(dif <= x) {
			val += max(a,b);
		}
		else {
			int c; cin >> c;
			val += c;
		}
	}
	cout << val << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...