Codeforces Round #422 (Div. 2) C
来源:互联网 发布:mac版单机游戏下载 编辑:程序博客网 时间:2024/06/07 07:05
参考http://www.cnblogs.com/fu3638/p/7111450.html和
http://blog.csdn.net/qq_34374664/article/details/74394895的
分析,他们这个地方的对于区间的处理挺好。的
而且vector看起来真好用,,不怕爆空间
typedef pair<int,int>pii;vector<pii>rv[mxn];vector<pii>v[mxn];map<int,int>mp;int main(){ //freopen("in.txt","r",stdin); int n,x;sf("%d%d",&n,&x); rep(i,1,n){ int l,r,c;sf("%d%d%d",&l,&r,&c);rv[l].push_back(pii(r,c));} int ans=2*1e9+1; for(int i=1;i<=2e5;++i){ for(int j=0;j<rv[i].size();++j){ int r=rv[i][j].first; int cost=rv[i][j].second; int tim=r-i+1; if(mp[x-tim]){ ans=min(ans,rv[i][j].second+mp[x-tim]); } v[r].push_back(pii(tim,cost)); } for(int j=0;j<v[i].size();++j){ int tim=v[i][j].first; int cost=v[i][j].second; if(!mp[tim]||mp[tim]>cost){ mp[tim]=cost; } } } if(ans==2*1e9+1)puts("-1"); else pf("%d\n",ans);}
阅读全文
0 0
- Codeforces Round #422 (Div. 2) C
- 【codeforces】Codeforces Round #370 (Div. 2) C
- Codeforces Round #422 (Div. 2)
- Codeforces Round #422 (Div. 2)
- Codeforces Round #422 (Div. 2)
- Codeforces Round #422 (Div. 2) C. Hacker, pack your bags!
- Codeforces Round #422 (Div. 2) C. Hacker, pack your bags!
- Codeforces Round #422 (Div. 2) A B C D
- Codeforces Round #105 (Div. 2) C
- Codeforces Round 134 div 2 C题
- Codeforces Round #137 (Div. 2), problem: (C)
- Codeforces Round #153 (Div. 2) C题
- Codeforces Round #158 (Div. 2) C题
- Codeforces Round #162 (Div. 2) C
- Codeforces Round #166 (Div. 2) c. Secret
- Codeforces Round#170(Div 2)C
- Codeforces Round #173 (Div. 2) Problem C
- Codeforces Round #192 (Div. 2) C. Purification
- Django 分页
- javascript声明对象
- 数据结构-从宏观上理解数据结构
- IO流,输入流输出流,字节流字符流
- fast-rcnn配置运行demo.py(Ubuntu14.04)
- Codeforces Round #422 (Div. 2) C
- Git对象
- 萌新的linux之旅19
- css表格间隙,分割线
- Word Ladder问题及解法
- s1569结构体,共用体,枚举
- Xshell连接本地VirtualBox中虚拟机Debian7.0.0
- ASCII 码简介
- java高并发分布式集群高可用网站系统架构实战