fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const long long oo = 1LL << 60;
  4.  
  5. struct SteelMill {
  6. long long cheapest(int goal, vector <int> shipmentCost, vector <int> shipmentSize, vector <int> costPerKg)
  7. {
  8. vector<long long> f(goal + 1, oo);
  9. f[0] = 0;
  10. for (int i = 0; i < shipmentCost.size(); i++)
  11. {
  12. vector<long long> newF = f;
  13. deque<pair<long long, int>> dq;
  14. dq.push_back({0, 0});
  15. for (int j = 1; j <= goal; j++)
  16. {
  17. while (j - dq.front().second > shipmentSize[i])
  18. dq.pop_front();
  19. newF[j] = min(newF[j], dq.front().first + 1LL * costPerKg[i] * j + shipmentCost[i]);
  20. long long value = f[j] - 1LL * costPerKg[i] * j;
  21. while (!dq.empty() && value <= dq.back().first)
  22. dq.pop_back();
  23. dq.push_back({value, j});
  24. }
  25. f = newF;
  26. }
  27. return f[goal];
  28. }
  29. };
  30.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty