---
# System prepended metadata

title: '【題解】apcs f605: 1. 購買力'
tags: [Zerojudge]

---

###### tags: `Zerojudge`
【題解】apcs f605: 1. 購買力
===
Posted on 2022/4/24 | By : Victoria1103
【題目敘述】https://zerojudge.tw/ShowProblem?problemid=f605



```cpp=
#include <iostream>
#include <algorithm>
using namespace std;

  int main()
{
  int n;
  int price[3];
  int d;
  int number=0;
  int money=0;
  cin >> n >> d;

  while (n--)
  {
  	for (int i=0;i<3;i++)
	  {
  	cin >> price[i];
	  }
  sort (price , price + 3);
  
  if (price[2]-price[0]>=d)
  {
  number++;
  money=money+(price[0]+price[1]+price[2])/3;
  }
  }
  cout << endl << number << " " << money;
  return 0; 
}