zoukankan      html  css  js  c++  java
  • Surf Gym

    //如果不慌应该比赛是能想出来的
    #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 ",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(" "); } printf("%I64d ",val); return 0; }
  • 相关阅读:
    Spring MVC3 + Ehcache 缓存实现
    DB2导入导出数据库数据
    JS、ActiveXObject、Scripting.FileSystemObject
    new ActiveXObject("Scripting.FileSystemObject") 时抛出异常 .
    各种浏览器的内核是什么
    Content-Type: application/vnd.ms-excel">
    常用jar包用途
    nutz的json视图
    Nutz中那些好用的工具类
    The JSP specification requires that an attribute name is preceded by whitespace
  • 原文地址:https://www.cnblogs.com/MeowMeowMeow/p/7486396.html
Copyright © 2011-2022 走看看