Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #ifdef JUDGE
  2. #include <fstream>
  3. #include <stdlib.h>
  4. std::ifstream cin("prepare.in");
  5. std::ofstream cout("prepare.out");
  6. #else
  7. #include <iostream>
  8. #include <stdlib.h>
  9. #endif
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. long long A,aux,cont=0,lA=0,lB=0;
  15. cin >> A;
  16. int listA[100],listB[100];
  17. for(int iA=0; iA<A; iA++){
  18. cin >> aux;
  19. listA[iA]=aux;
  20. }
  21. for(int iB=0; iB<A;iB++){
  22. cin >> aux;
  23. listB[iB]=aux;
  24. }
  25. for(int iA=0; iA<A;iA++){
  26. if(listA[iA]>=listB[iA]){
  27. cont += listA[iA];
  28. lA++;
  29. }else{
  30. cont += listB[iA];
  31. lB++;
  32. }
  33. }
  34. if(lA == 0 || lB == 0){
  35. if(lA==0){
  36. aux=0;
  37. for(int iA=0; iA<iA;iA++){
  38. if(iA == 0){
  39. //aux=0;
  40. }else if(listB[iA]-listA[iA]<listB[aux]-listA[aux]){
  41. aux = iA;
  42. }
  43. }
  44. }else{
  45. aux=0;
  46. for(int iA=0; iA<A;iA++){
  47. if(iA == 0){
  48. //aux=0;
  49. }else if(listA[iA]-listB[iA]<listA[aux]-listB[aux]){
  50. aux = iA;
  51. }
  52. }
  53. }
  54. cont -= abs(listA[aux]-listB[aux]);
  55. }
  56. cout << cont << endl;
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement