fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int compare(int a,int b)
  6. {
  7. return a > b;
  8. }
  9. int main() {
  10. // your code goes here
  11. int t, n;
  12. cin >> t >> n;
  13. int a[160],b[160];
  14. while(t--)
  15. {
  16. int score_sum[160] = {0},foul_sum[160] = {0};
  17. for(int i = 0;i < n;i++)
  18. {
  19. cin >> a[i];
  20. score_sum[i] += a[i] * 20;
  21. }
  22. for(int i = 0;i < n;i++)
  23. {
  24. cin >> b[i];
  25. foul_sum[i] += b[i] * 10;
  26. }
  27. int net_sum[n] = {0};
  28. for(int i = 0;i < n;i++)
  29. {
  30. net_sum[i] = score_sum[i] - foul_sum[i];
  31. if(net_sum[i] <= 0)
  32. net_sum[i] = 0;
  33. }
  34. sort(net_sum, net_sum + n,compare);
  35. cout << net_sum[0] << endl;
  36. }
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 4392KB
stdin
2
3
40 30 50
2 4 20
1
0
10
stdout
800
0