Posted By

dirkchang on 03/03/11


Tagged


Versions (?)

Gattaca


 / Published in: C++
 

  1. /*
  2.  * =====================================================================================
  3.  *
  4.  * Filename: gattaca.cpp
  5.  *
  6.  * Author: Dirk Chang (), [email protected]
  7.  *
  8.  * =====================================================================================
  9.  */
  10.  
  11. #include "was.hpp"
  12.  
  13. #include <iostream>
  14. #include <string>
  15. #include <fstream>
  16. #include <cmath>
  17. using namespace std;
  18.  
  19. int main(int argc, char **argv) {
  20. int n(0), g(0), line(0), start(0), finish(0), weight(0);
  21. double const MAX_LINE = 80;
  22. string input;
  23. WeightedActivitySelection<> was;
  24.  
  25. ifstream fin(argv[1]);
  26. fin >> n;
  27. line = ceil(n/MAX_LINE);
  28. fin.seekg(n+line, ios::cur);
  29. fin >> g;
  30. was.SetN(g);
  31. for(int i = 1; i <= g; ++i) {
  32. fin >> start >> finish >> weight;
  33. was.GetList()[i].Set(start, finish , weight);
  34. }
  35. cout << was.Compute() << '\n';
  36. }

Report this snippet  

You need to login to post a comment.