Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #ifdef ACMTUYO
  6. struct RTC{~RTC(){cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC <<" seconds\n";}} runtimecount;
  7. #define DBG(X) cerr << #X << " = " << X << '\n';
  8. #else
  9. struct RTC{};
  10. #define DBG(X)
  11. #endif
  12.  
  13. #define fast_io() ios_base::sync_with_stdio(false)
  14. #define mp make_pair
  15. #define mt make_tuple
  16. #define pb push_back
  17. #define eb emplace_back
  18. #define sz(x) ((int)(x).size())
  19. #define all(c) (c).begin(),(c).end()
  20. #define forn(i, n) for (int i = 0; i < (n); i++)
  21. typedef long long int number;
  22.  
  23. struct team{
  24. string nombre;
  25. int t;
  26. int p[20];
  27. int ac;
  28. team() {
  29. }
  30. team(string n) {
  31. nombre = n;
  32. t = 0;
  33. ac = 0;
  34. for(int i = 0; i < 20; i++)
  35. p[i] = 0;
  36. }
  37. void penalizar(int problem) {
  38. p[problem]++;
  39. }
  40. void accepted(int problem,int tiempo) {
  41. t += p[problem] * 20 + tiempo;
  42. ac++;
  43. }
  44. };
  45. vector<team> v;
  46. string myteam;
  47. int main() {
  48. int n,envios,problemas;
  49. cin>>n>>envios>>problemas;
  50. string s;
  51. for(int i = 0; i < n; i++) {
  52. cin>>s;
  53. team x(s);
  54. v.push_back(x);
  55. }
  56. myteam = v[0].nombre;
  57. string nom,id,resp;
  58. int tenvio;
  59. int start = 0, ans = 0;
  60. for(int i = 0; i < envios; i++) {
  61. cin>>nom>>id>>tenvio>>resp;
  62. int index = -1;
  63. for(int j = 0; j < n; j++) {
  64. if(v[j].nombre == nom) {
  65. index = j;
  66. break;
  67. }
  68. }
  69. string lider = v[0].nombre;
  70. //cout<<i<<": Lider "<<lider<<endl;
  71. if(resp == "NO"){
  72. v[index].penalizar(id[0] - 'A');
  73. }else {
  74. v[index].accepted(id[0] - 'A', tenvio);
  75. while(index > 0) {
  76. if(v[index].ac > v[index - 1].ac) {
  77. swap(v[index],v[index - 1]);
  78. }else {
  79. if(v[index].ac == v[index - 1].ac) {
  80. if(v[index].t < v[index - 1].t) {
  81. swap(v[index],v[index - 1]);
  82. }else {
  83. break;
  84. }
  85. }else {
  86. break;
  87. }
  88. }
  89. index--;
  90. }
  91. if(lider != v[0].nombre) {
  92. if(lider == myteam) {
  93. ans += (tenvio - start);
  94. }else {
  95. if(v[0].nombre == myteam) {
  96. // cout<<"inicio en: "<<tenvio<<endl;
  97. start = tenvio;
  98. }
  99. }
  100. }
  101. }
  102. }
  103. cout<<ans<<"\n";
  104. return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement