HNU 12836 Fox Observation
来源:互联网 发布:凡人修真2源码 编辑:程序博客网 时间:2024/04/30 02:28
题目:
http://acm.hnu.cn/online/?action=problem&type=show&id=12836
对于这题我只能说一句我SB了。。。
训练赛的时候,我就想到两个区域一定不能合并,合并之后结果 肯定会变小。。
所以我当时就想找两个点(我当时以为是找两个有狐狸的点)构成一个中间没有其他点矩形,然后找N/( (x1-x2) * (y1-y2) ) 最大值即可
现在我才发现越来我理解错题意了。。。
是任意找两个点(两个点的x轴和y轴都不能一样)就可以了。。。
如果是任意两个点的话,所以我们只要找一个边长为1的正方形就可以了,想一想 如果面积不为1,找到的区域肯定就是可以用其他区域合并的,绝笔不是最优解
代码:
#include <cstdio>#include <algorithm>#include <cstring>using namespace std;#define maxn 100005struct node{int x, y;int v;}a[maxn];int cmp(node x, node y){ return x.y< y.y;}int max(int x, int y){return x> y? x: y;}int main(){int n;while(scanf("%d",&n)!=EOF){for(int i= 1; i<= n; i++)scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].v);sort(a+1, a+n+1, cmp);int ans= 0;for(int i= 1,j= 2; i< n; i++){int res= a[i].v;if(a[i].y== a[i+1].y && a[i].x + 1== a[i+1].x)res+= a[i+1].v;while(j<= n && a[j].y<= a[i].y)j++;if(a[i].x== a[j].x && a[j].y== a[i].y+1 ){res+= a[j].v;j++;}if(a[i].x+ 1== a[j].x && a[i].y+1 == a[j].y)res+= a[j].v;ans= max(ans, res);}printf("%d / 1\n",ans);}return 0;}
0 0
- HNU 12836 Fox Observation
- Fox Observation
- hnu 13052 What does the fox say?
- EOLi (Earth Observation Link)
- HNU 11877
- hnu 病毒
- hnu 12948
- HNU Profits
- HNU 21
- Activity 生命周期观察-Android Activity Lifecycle Observation
- IOS Dev Intro - Delegation Notification and Observation
- 不是FOX
- 【Srm590】Fox And City(fox)
- 【Srm590】Fox And City(fox)
- acm hnu 10136 Palindromes
- hnu 12029 LCA问题
- hnu 12439 #贪心
- [讨论]hnu 12450 Painting
- 杭电ACM 1042 N!(还需再看)
- 求最大公约数和最小公倍数
- 分布式session处理方案
- Actionbar 溢出菜单背景色设置
- 有一字符串,包含数字与字母,如何用指针编程去除数字。
- HNU 12836 Fox Observation
- APUE第八章 进程控制
- [quick-cocos2dx] umeng command
- 黑马程序员——数组排列计算
- ubuntu14.04挂载nfs
- javase的复习------1
- get和post的区别,你真的理解吗?
- Highways(prim——最小生成树)
- 如何去除导航栏底端线条