Advertisement
Guest User

reducao de pena

a guest
Jul 23rd, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. typedef struct tarefa{
  7. int pontos;
  8. int inicio;
  9. int final;
  10.  
  11. } tarefa;
  12.  
  13. int main (){
  14. int n;
  15. while(cin >> n && n){
  16. int i, j;
  17. int codigo;
  18. int pontos;
  19. char dia[4];
  20. int inicio;
  21. int final;
  22.  
  23. set<int> vseg;
  24. set<int> vter;
  25. set<int> vqua;
  26. set<int> vqui;
  27. set<int> vsex;
  28.  
  29. vector<tarefa> tarefaseg;
  30. vector<tarefa> tarefater;
  31. vector<tarefa> tarefaqua;
  32. vector<tarefa> tarefaqui;
  33. vector<tarefa> tarefasex;
  34.  
  35.  
  36. for (i = 0; i< n; i++){
  37. int h1, m1;
  38. int h2, m2;
  39.  
  40. scanf("%d %d %s %d:%d %d:%d", &codigo, &pontos, dia, &h1, &m1, &h2, &m2);
  41.  
  42. inicio = h1*60+m1;
  43. final = h2*60+m2;
  44.  
  45. tarefa t;
  46. t.pontos = pontos;
  47. t.inicio = inicio;
  48. t.final = final;
  49.  
  50. if ((dia[0]=='S')&&(dia[1]=='e')&&(dia[2]=='g')){
  51. tarefaseg.push_back(t);
  52. } else if ((dia[0]=='T')&&(dia[1]=='e')&&(dia[2]=='t')){
  53. tarefater.push_back(t);
  54. } else if ((dia[0]=='Q')&&(dia[1]=='u')&&(dia[2]=='a')){
  55. tarefaqua.push_back(t);
  56. } else if ((dia[0]=='Q')&&(dia[1]=='u')&&(dia[2]=='i')){
  57. tarefaqui.push_back(t);
  58. } else if ((dia[0]=='S')&&(dia[1]=='e')&&(dia[2]=='x')){
  59. tarefasex.push_back(t);
  60. }
  61. }
  62.  
  63.  
  64. for (i = 0; i < tarefaseg.size(); i++){
  65.  
  66. tarefa t1 = tarefaseg.at(i);
  67. int sum = t1.pontos;
  68. for (j = 0; j < tarefaseg.size(); j++){
  69. tarefa t2 = tarefaseg.at(j);
  70.  
  71. if ( (t1.inicio < t2.inicio) && (t2.final < t2.final) ){
  72. sum += t2.pontos;
  73. }
  74.  
  75. }
  76.  
  77. vseg.insert(sum);
  78.  
  79.  
  80. }
  81.  
  82.  
  83.  
  84. int seg = *vseg.end();
  85. int ter = *vter.end();
  86. int qua = *vqua.end();
  87. int qui = *vqui.end();
  88. int sex = *vsex.end();
  89. int total = seg + ter + qua + qui + sex;
  90. cout << "Total de pontos: " << total << endl;
  91. cout << "Seg: " << seg << endl;
  92. cout << "Ter: " << ter << endl;
  93. cout << "Qua: " << qua << endl;
  94. cout << "Qui: " << qui << endl;
  95. cout << "Sex: " << sex << endl;
  96. }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement