又是一道没a的题。。。

YJJ is a salesman who has traveled through western country. YJJ is always on journey. Either is he at the destination, or on the way to destination. 
One day, he is going to travel from city A to southeastern city B. Let us assume that A is (0,0)(0,0) on the rectangle map and B (109,109)(109,109). YJJ is so busy so he never turn back or go twice the same way, he will only move to east, south or southeast, which means, if YJJ is at (x,y)(x,y) now (0≤x≤109,0≤y≤109)(0≤x≤109,0≤y≤109), he will only forward to (x+1,y)(x+1,y), (x,y+1)(x,y+1) or (x+1,y+1)(x+1,y+1). 
On the rectangle map from (0,0)(0,0) to (109,109)(109,109), there are several villages scattering on the map. Villagers will do business deals with salesmen from northwestern, but not northern or western. In mathematical language, this means when there is a village kk on (xk,yk)(xk,yk) (1≤xk≤109,1≤yk≤109)(1≤xk≤109,1≤yk≤109), only the one who was from (xk−1,yk−1)(xk−1,yk−1) to (xk,yk)(xk,yk) will be able to earn vkvk dollars.(YJJ may get different number of dollars from different village.) 
YJJ has no time to plan the path, can you help him to find maximum of dollars YJJ can get.

The first line of the input contains an integer TT (1≤T≤10)(1≤T≤10),which is the number of test cases.

In each case, the first line of the input contains an integer NN (1≤N≤105)(1≤N≤105).The following NN lines, the kk-th line contains 3 integers, xk,yk,vkxk,yk,vk (0≤vk≤103)(0≤vk≤103), which indicate that there is a village on (xk,yk)(xk,yk) and he can get vkvk dollars in that village. 
The positions of each village is distinct.

题意很明显,简单题。。。结果还是没过,,自己真是个辣鸡

然后看数据写代码吧。。 代码1000+ms

1e9 离散化 然后x相等时 y从大到小更新就行了

1e5  nlogn  线段树或者树状数组   朴素的n2肯定t了。。

一直写线段树,,一直tle。。忘记了树状数组这货。。

还是树状数组的常数小呀。。

#include<cstring>
#include<cmath>
#include<string.h>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdio>
#define lowbit(x) (x&(-x))
int read() {int x = 0;char c = getchar();while (c < '0' || c > '9')c = getchar();while (c >= '0' && c <= '9') {x = x * 10 + c - '0';c = getchar();}return x;
}
int cnt; struct node{int x,y;int value;
};
using namespace std;
int dp[400005];
int y[100005];
node data[100005];int n;
bool cmp(node a,node b)
{if(a.x<b.x)return 1;else if(a.x==b.x&&a.y<b.y)return 1;else return 0;
}void updata(int u,int k)
{for(int i=u;i<=cnt;i+=lowbit(i)){dp[i]=max(dp[i],k);}
}int query(int u)
{int res=0;for(int i=u;i>0;i-=lowbit(i)){res=max(res,dp[i]);}return res;
}int main(){int T;T=read();while(T--){n=read();memset(dp,0,sizeof(dp));for(int i=0;i<n;i++){   data[i].x=read();   data[i].y=read();  data[i].value=read();          }       sort(data,data+n,cmp);         for(int i=0;i<n;i++){        y[i]=data[i].y;                             }sort(y,y+n);cnt=unique(y,y+n)-y; for(int i=0;i<n;i++){    data[i].y=lower_bound(y,y+cnt,data[i].y)-y+1;}       int m=0;       for(int i=0;i<n;i++){     int j=i;int temp=data[i].x;while((data[i+1].x==temp)&&(i<n)){i++; }                   for(int z=i;z>=j;z--){dp[data[z].y]=max(query(data[z].y-1)+data[z].value,dp[data[z].y]);updata(data[z].y,dp[data[z].y]);m=max(m,dp[data[z].y]);}    }printf("%d\n",m);}
}

2018ccpc网络赛1010 J - YJJ's Salesman相关推荐

  1. 2018CCPC网络赛 HDU 6444: G. Neko's loop(线段树)

    Neko's loop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tota ...

  2. 【2018ccpc网络赛1008】【hdu6445】Search for Answer 题解

    题目大意 ~~~~~~      有一幅竞赛图(n<=200),其中一些边未定向( s[i][j]=1s[i][j]=1s[i][j]=1 且 s[j][i]=0s[j][i]=0s[j][i] ...

  3. HDU 6445 2018CCPC网络赛1008 Search for Answer(费用流 + 构图)

    大致题意:给你一个竞赛图,告诉你一个记数方法,也即所有边同向的四元组加一,所有相邻两边方向相反的四元组减一.现在让你最大化这个结果. 说实话,不看题解应该很难想到是一个费用流--题解给的也真是简单,个 ...

  4. 2018CCPC网络赛

    https://blog.csdn.net/qq_37891604/article/details/82078998 https://blog.csdn.net/qq_37891604/article ...

  5. CCPC 2018网络预赛 hdu 6447 YJJ's Salesman

    [题目链接] 题目意思 T组案例,给一个n,下面n行,每行三个数字(x,y,v)表示点(x,y)处的值为v,只有当从(x-1,y-1)走到(x,y)时,才能获得点(x,y)的v值,求从(0,0)走到( ...

  6. 2018CCPC网络赛 部分题解

    1001:传送门 dalao的题解:https://www.cnblogs.com/Lin88/p/9537354.html 1002:传送门 dalao的题解:https://www.zybuluo ...

  7. ACM网络赛金华赛区的一道关于树的题:Family Name List

    三场网络赛终于告一段落了!唉,实力太弱了!跟北大.清华这些家伙差距太远了,比"我在你身边你却不知道我爱你"的距离还要远! 这道题没有来得及提交,自己下来写完的,把样例过了!留在博客 ...

  8. 乌鲁木齐网络赛J题(最小费用最大流模板)

    ACM ICPC 乌鲁木齐网络赛 J. Our Journey of Dalian Ends 2017-09-09 17:24 243人阅读 评论(0) 收藏 举报  分类: 网络流(33)  版权声 ...

  9. J Red-Black Paths(ICPC网络赛第一场)

    J Red-Black Paths(ICPC网络赛第一场) 题意: 有n个点,m次操作,有三种操作: 1 u v:从u向v建一个有向边 2 u:将点u染成红色 3 u: 将点u染成黑色 4 查询最新生 ...

最新文章

  1. 字符串操作:索引位置、去空格、替换字符串
  2. QT的QQmlExtensionPlugin类的使用
  3. asp中正则表达式应用
  4. 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。
  5. C++11: std::function<void()> func
  6. property的修饰符
  7. 字符串按照单词为单位逆序排列
  8. 发布你的程序包到Nuget
  9. docker学习之-什么是docker
  10. Win7使用之查端口,杀进程
  11. JSON与JAVA的数据转换
  12. 数学建模6 典型相关分析
  13. Intellij idea 插件 | 超越鼓励师 吐槽
  14. Yate软交换机IPPBX与电话语音网关的初步配合
  15. 体胖还需勤跑步,人丑就该多读书!
  16. python爬虫网页崩溃怎么处理_python程序爬虫总是崩溃
  17. HTML5在线电影网站设计 黑色的影视传媒公司网站(6页) HTML+CSS+JavaScript
  18. 腰椎间盘突出,睡硬床垫还是软床垫好?听骨科医生答疑
  19. 【机器学习】详解 转置卷积 (Transpose Convolution)
  20. 人工智能和机器学习在改善客户体验方面的应用

热门文章

  1. 每日一题 No.4 男女搭配干活不累
  2. 自考本科英语(二)学习笔记和考试经验
  3. app的崩溃率标准,优秀,合格,轻微隐患,严重隐患
  4. “压缩(zipped)文件夹“G:\Program\Wechat WeChatFiles(wxid cqpx72n77z9x22 FileStorage\File 2022-12 基...
  5. Python批量修改文件后缀
  6. 深圳软件测试培训:软件生命周期(SDLC)的六个阶段
  7. 数据结构2.带控制信息的链表
  8. android miui连接开发者选项,(最详细)MIUI11系统的Usb调试模式在哪里开启的步骤
  9. 阿里云ID2物联网设备身份认证系统
  10. HTML 笔记/案例