Mikki0

Untitled

Sep 20th, 2021
1,051
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. struct Node {
  8.     long long cost;
  9.     long long length, deadline;
  10. };
  11.  
  12. bool comparator(Node& a, Node& b) {
  13.     return tie(a.length, a.deadline) < tie(b.length, b.deadline);
  14. }
  15.  
  16. int main() {
  17.     freopen("input.txt", "r", stdin);
  18.     freopen("output.txt", "w", stdout);
  19.     long long n;
  20.     cin >> n;
  21.     vector<Node> v;
  22.     for (long long i = 0; i < n; ++i) {
  23.         long long a, b, c;
  24.         cin >> a >> b >> c;
  25.         v.push_back({a, b, c});
  26.     }
  27.     sort(v.begin(), v.end(), comparator);
  28.     long long answer = 0;
  29.     long long cur_day = 0;
  30.     for (long long i = 0; i < n; ++i) {
  31.         answer += v[i].cost;
  32.         cur_day += v[i].length;
  33.         answer += 100 * (v[i].deadline - cur_day);
  34.     }
  35.     cout << answer << '\n';
  36. }
RAW Paste Data