Surf Gym - 100819S

//如果不慌应该比赛是能想出来的
#include <iostream> #include <algorithm> #include <stdio.h> #include <set> #include <queue> #include <cstring> #include <string> #include <limits.h> #include <string.h> #include <vector> #include <map> #define LL long long #define INF 2100000000 #define fi first #define se second #define lowbit(x) (x&(-x)) #define eps 5e-7 using namespace std; const int maxn=(int)3e5 +10; const int maxm=(int)2510; const LL MOD=(LL)1e9+7; int n; struct nod{ int x,y;LL z; void in(){ scanf("%d%I64d%d",&x,&z,&y);y+=x; } nod(){} nod(int x,int y,LL z):x(x),y(y),z(z){} bool operator <(const nod&a)const{ return y==a.y&&x<a.x||y<a.y; } }; nod f[maxn]; int main() { #ifdef shuaishuai freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin); //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout); #endif int n; scanf("%d",&n); for(int i=0;i<n;i++ ){ f[i].in(); } sort(f,f+n) ; for(int i=1;i<n;i++){ if(f[i].x>=f[i-1].y) f[i].z+=f[i-1].z; else{ int k=upper_bound(f,f+i,nod(f[i].x,f[i].x,0))-f-1; f[i].z=max(f[i-1].z,f[k].z+f[i].z); } } printf("%I64d\n",f[n-1].z); return 0; }

 

//优秀的标程啊 不过我留了个bug在里面 =。=
int
n; struct nod{ int t; LL s; int idx; nod(){} nod(int t,LL s,int idx):t(t),s(s),idx(idx){} bool operator <(const nod&a)const {return t<a.t;} }; vector<nod> q; LL st[maxn]; int main() { #ifdef shuaishuai freopen("C:\\Users\\hasee\\Desktop\\a.txt","r",stdin); //freopen("C:\\Users\\hasee\\Desktop\\b.txt","w",stdout); #endif int x,y;LL s; scanf("%d",&n); q.reserve(2*n); for(int i=0;i<n;i++){ scanf("%d%I64d%d",&x,&s,&y); q.push_back(nod(x,0,i));q.push_back(nod(x+y,s,i)); } sort(q.begin(),q.end()); LL val=0; for(int i=0;i<q.size();i++){ if(q[i].s==0) st[q[i].idx]=val; else{ val=max(val,st[q[i].idx]+q[i].s); } // for(int i=0;i<n;i++)printf("%lld ",st[i]);printf("\n"); } printf("%I64d\n",val); return 0; }

 

转载于:https://www.cnblogs.com/MeowMeowMeow/p/7486396.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值