Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3. #include <deque>
  4. #include <queue>
  5. #include <string>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <vector>
  9. #include <cstdio>
  10. #include <map>
  11. #include <set>
  12. using namespace std;
  13. typedef long long ll;
  14. typedef pair<int, int> pii;
  15. #define mp make_pair
  16. #define fi first
  17. #define se second
  18. #define pb push_back
  19. #define fo(i,k,n) for(size_t i=k; (int)i<n; ++i)
  20. #define sz(a) a.size()
  21.  
  22. ll t,w,f,n,m;
  23. ll best;
  24. ll can[2*1000100];
  25. vector<pair<ll,ll>> all[2*1000100];
  26.  
  27.  
  28. int main(){
  29.  
  30. scanf("%lld", &n);
  31.  
  32. fo(i,1,n+1){
  33.  
  34. scanf("%lld%lld%lld", &m,&f,&w);
  35. all[m].pb(mp(f,w));
  36.  
  37. }
  38.  
  39. fo(i,0,2000000){
  40.  
  41. best = max(best, can[i]);
  42.  
  43. fo(j,0,sz(all[i])){
  44.  
  45. ll fun = all[i][j].fi;
  46. ll ti = all[i][j].se;
  47.  
  48. can[i+ti] = max(can[i+t], best + fun);
  49.  
  50. }
  51. }
  52.  
  53. cout<<best;
  54.  
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement