Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- #include <deque>
- #include <queue>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <cstdio>
- #include <map>
- #include <set>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> pii;
- #define mp make_pair
- #define fi first
- #define se second
- #define pb push_back
- #define fo(i,k,n) for(size_t i=k; (int)i<n; ++i)
- #define sz(a) a.size()
- ll t,w,f,n,m;
- ll best;
- ll can[2*1000100];
- vector<pair<ll,ll>> all[2*1000100];
- int main(){
- scanf("%lld", &n);
- fo(i,1,n+1){
- scanf("%lld%lld%lld", &m,&f,&w);
- all[m].pb(mp(f,w));
- }
- fo(i,0,2000000){
- best = max(best, can[i]);
- fo(j,0,sz(all[i])){
- ll fun = all[i][j].fi;
- ll ti = all[i][j].se;
- can[i+ti] = max(can[i+t], best + fun);
- }
- }
- cout<<best;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement