本文为 CCF 认证学习笔记,讲解题目回收站选址。欢迎在评论区与我交流😊
【传送门】
方法一:简单模拟
思路
首先筛选符合要求的垃圾堆,找出垃圾站存在向量中。然后统计每个垃圾站的得分并输出。
代码
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int n;
vector<pair<ll, ll>> trash, station;
// 判断是否为垃圾站
bool isStation(int index){
int cnt = 0;
ll _x = trash[index].first, _y = trash[index].second;
for(int i = 0; i < n; ++i){
if(i == index) continue;
if(_x