fork(1) download
  1. /*
  2.  *
  3.  ********************************************************************************************
  4.  * AUTHOR : Vijju123 *
  5.  * Language: C++14 *
  6.  * Purpose: - *
  7.  * IDE used: Codechef IDE. *
  8.  ********************************************************************************************
  9.  *
  10.  Comments will be included in practice problems if it helps ^^
  11.  */
  12.  
  13.  
  14.  
  15. #include <iostream>
  16. #include<bits/stdc++.h>
  17. using namespace std;
  18.  
  19. //I never understand why people put useless functions at top of code. Makes it so unreadable ughhhh.
  20.  
  21. long long readInt(long long l,long long r,char endd){
  22. long long x=0;
  23. int cnt=0;
  24. int fi=-1;
  25. bool is_neg=false;
  26. while(true){
  27. char g=getchar();
  28. if(g=='-'){
  29. assert(fi==-1);
  30. is_neg=true;
  31. continue;
  32. }
  33. if('0'<=g && g<='9'){
  34. x*=10;
  35. x+=g-'0';
  36. if(cnt==0){
  37. fi=g-'0';
  38. }
  39. cnt++;
  40. assert(fi!=0 || cnt==1);
  41. assert(fi!=0 || is_neg==false);
  42.  
  43. assert(!(cnt>19 || ( cnt==19 && fi>1) ));
  44. } else if(g==endd){
  45. if(is_neg){
  46. x= -x;
  47. }
  48. if(!(l<=x && x<=r))cerr<<l<<"<="<<x<<"<="<<r<<endl;
  49. assert(l<=x && x<=r);
  50. return x;
  51. } else {
  52. assert(false);
  53. }
  54. }
  55. }
  56. string readString(int l,int r,char endd){
  57. string ret="";
  58. int cnt=0;
  59. while(true){
  60. char g=getchar();
  61. assert(g!=-1);
  62. if(g==endd){
  63. break;
  64. }
  65. cnt++;
  66. ret+=g;
  67. }
  68. assert(l<=cnt && cnt<=r);
  69. return ret;
  70. }
  71. long long readIntSp(long long l,long long r){
  72. return readInt(l,r,' ');
  73. }
  74. long long readIntLn(long long l,long long r){
  75. return readInt(l,r,'\n');
  76. }
  77. string readStringLn(int l,int r){
  78. return readString(l,r,'\n');
  79. }
  80. string readStringSp(int l,int r){
  81. return readString(l,r,' ');
  82. }
  83.  
  84.  
  85.  
  86. int main() {
  87. // your code goes here
  88. #ifdef JUDGE
  89. string in,out;
  90. cin>>in>>out;
  91. in+=".in";
  92. if(in!="z.in")
  93. out+=".out";
  94. else out+=".in";
  95. if(in!="z.in")
  96. freopen(in.c_str(), "rt", stdin);
  97. freopen(out.c_str(), "wt", stdout);
  98. #endif
  99. ios_base::sync_with_stdio(0);
  100. cin.tie(NULL);
  101. cout.tie(NULL);
  102. srand(time(NULL));
  103. //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  104.  
  105. int t=readIntLn(1,10);
  106. while(t--)
  107. {
  108. int n=readIntLn(1,1000);
  109.  
  110. //Decl and Init
  111. int score[100];
  112. memset(score,0,sizeof(score));
  113. int p,s;
  114.  
  115. while(n--)
  116. {
  117. p=readIntSp(1,11);
  118. s=readIntLn(0,100);
  119. score[p]=max(score[p],s);
  120. }
  121.  
  122. int ans=0;
  123. for(int i=1;i<=8;i++)ans+=score[i];
  124.  
  125. cout<<ans<<endl;
  126. }
  127.  
  128. assert(getchar()==-1);
  129. return 0;
  130. }
  131.  
Runtime error #stdin #stdout #stderr 0s 4340KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:52: long long int readInt(long long int, long long int, char): Assertion `false' failed.