# ZeroJudge - f605: 1. 購買力 ### 題目連結:https://zerojudge.tw/ShowProblem?problemid=f605 ###### tags: `ZeroJudge` ```cpp= #include <iostream> #include <algorithm> using namespace std; int main() { cin.sync_with_stdio(false); cin.tie(nullptr); int products, difference, prices[3], average, counts, total; while (cin >> products >> difference) { counts = total = 0; while (products--) { average = 0; for (int i = 0; i < 3; ++i) cin >> prices[i], average += prices[i]; sort(prices, prices + 3); if (prices[2] - prices[0] >= difference) ++counts, total += average / 3; } cout << counts << ' ' << total << '\n'; } } ```