记录编号 |
310646 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2014]无线网路发射器选址 |
最终得分 |
100 |
用户昵称 |
BillAlen |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.073 s |
提交时间 |
2016-09-22 20:44:01 |
内存使用 |
0.34 MiB |
显示代码纯文本
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int d = 0, n = 0, crosses[129][129], maxCoverPlaces = 0, plans = 0;
int canCoverPlaces(int posx, int posy){
int minx = max(0, posx - d), maxx = min(128, posx + d),
miny = max(0, posy - d), maxy = min(128, posy + d);
int tmpc = 0;
for(int i = minx; i <= maxx; i++)
for(int j = miny; j <= maxy; j++)
tmpc += crosses[i][j];
return tmpc;
}
int main(){
fstream in("wireless.in", ios::in), out("wireless.out", ios::out);
in >> d >> n;
for(int i = 0; i < n; i++){
int a = 0, b = 0;
in >> a >> b;
in >> crosses[a][b];
}
for(int i = 0; i < 129; i++)
for(int j = 0; j < 129; j++){
int tmpc = canCoverPlaces(i, j);
if(tmpc > maxCoverPlaces){
maxCoverPlaces = tmpc;
plans = 1;
}else if(tmpc == maxCoverPlaces){
plans++;
}
}
out << plans << " " << maxCoverPlaces;
return 0;
}