Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef JUDGE
- #include <fstream>
- #include <stdlib.h>
- std::ifstream cin("prepare.in");
- std::ofstream cout("prepare.out");
- #else
- #include <iostream>
- #include <stdlib.h>
- #endif
- using namespace std;
- int main()
- {
- long long A,aux,cont=0,lA=0,lB=0;
- cin >> A;
- int listA[100],listB[100];
- for(int iA=0; iA<A; iA++){
- cin >> aux;
- listA[iA]=aux;
- }
- for(int iB=0; iB<A;iB++){
- cin >> aux;
- listB[iB]=aux;
- }
- for(int iA=0; iA<A;iA++){
- if(listA[iA]>=listB[iA]){
- cont += listA[iA];
- lA++;
- }else{
- cont += listB[iA];
- lB++;
- }
- }
- if(lA == 0 || lB == 0){
- if(lA==0){
- aux=0;
- for(int iA=0; iA<iA;iA++){
- if(iA == 0){
- //aux=0;
- }else if(listB[iA]-listA[iA]<listB[aux]-listA[aux]){
- aux = iA;
- }
- }
- }else{
- aux=0;
- for(int iA=0; iA<A;iA++){
- if(iA == 0){
- //aux=0;
- }else if(listA[iA]-listB[iA]<listA[aux]-listB[aux]){
- aux = iA;
- }
- }
- }
- cont -= abs(listA[aux]-listB[aux]);
- }
- cout << cont << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement