"cses projects solution" Code Answer's

You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "cses projects solution" answered properly. Developers are finding an appropriate answer about cses projects solution related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like cses projects solution. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on cses projects solution. 

cses projects solution

By Poised PeccaryPoised Peccary on Nov 06, 2020
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  map<int,int> compress;
  vector<int> a(n),b(n),p(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> p[i];
    b[i]++;
    compress[a[i]], compress[b[i]];
  }

  int coords = 0;
  for (auto&v : compress) {
    v.second = coords++;
  }

  vector<vector<pair<int,int>>> project(coords);
  for (int i = 0; i < n; i++) {
    project[ compress[b[i]] ].emplace_back( compress[a[i]], p[i] );
  }

  vector<long long> dp(coords, 0);
  for (int i = 0; i < coords; i++) {
    if (i > 0) {
      dp[i] = dp[i-1];
    }
    for (auto p : project[i]) {
      dp[i] = max(dp[i], dp[p.first]+p.second);
    }
  }
  cout << dp[coords-1] << endl;
}

Source: codeforces.com

Add Comment

0

All those coders who are working on the TypeScript based application and are stuck on cses projects solution can get a collection of related answers to their query. Programmers need to enter their query on cses projects solution related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about cses projects solution for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of cses projects solution while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "cses projects solution". Visit this developer's friendly online web community, CodeProZone, and get your queries like cses projects solution resolved professionally and stay updated to the latest TypeScript updates. 

TypeScript answers related to "cses projects solution"

View All TypeScript queries

TypeScript queries related to "cses projects solution"

Browse Other Code Languages

CodeProZone