fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. int monsters;
  10. cin>>monsters;
  11. int level[monsters];
  12. for(int i=0;i<monsters;i++)
  13. cin>>level[i];
  14. int currLvl=0,exp=0;
  15. for(int i=0;i<monsters;i++)
  16. {
  17. if(level[i]<currLvl)
  18. continue;
  19. else //level[i]>=currLvl
  20. {
  21. currLvl=level[i];
  22. exp+=level[i];
  23. }
  24. }
  25. cout<<exp<<endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 16048KB
stdin
1
5
1 2 3 4 5
stdout
15