fork download
  1. #include <cmath>
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <string>
  6. #include <set>
  7. #include <map>
  8. #include <list>
  9. #include <time.h>
  10. #include <math.h>
  11. #include <random>
  12. #include <deque>
  13. #include <queue>
  14. #include <cassert>
  15. #include <unordered_map>
  16. #include <unordered_set>
  17. #include <iomanip>
  18. #include <bitset>
  19. #include <sstream>
  20. #include <chrono>
  21. #include <cstring>
  22.  
  23. using namespace std;
  24.  
  25. typedef long long ll;
  26.  
  27. #ifdef iq
  28. mt19937 rnd(228);
  29. #else
  30. mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
  31. #endif
  32.  
  33. int main() {
  34. #ifdef iq
  35. freopen("a.in", "r", stdin);
  36. #endif
  37. ios::sync_with_stdio(0);
  38. cin.tie(0);
  39. int t;
  40. cin >> t;
  41. while (t--) {
  42. int n;
  43. cin >> n;
  44. vector <int> ans(8);
  45. for (int i = 0; i < n; i++) {
  46. int p, s;
  47. cin >> p >> s;
  48. p--;
  49. if (p < 8) {
  50. ans[p] = max(ans[p], s);
  51. }
  52. }
  53. int sum = 0;
  54. for (int i = 0; i < 8; i++) sum += ans[i];
  55. cout << sum << '\n';
  56. }
  57. }
Runtime error #stdin #stdout #stderr 0s 4488KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
free(): invalid size