SRM 307 DIV 2 (250)

Programming/SRM Practice 2009. 7. 4. 06:53
SRM 307 DIV 2 (250)
문제 요약 : 짝이 맞지 않아서 교환해야하는 신발은 총 몇 켤레인가? 

#include <iostream>

#include <vector>

using namespace std;

 

class BootsExchange

{

public:

        int leastAmount(vector <int> left, vector <int> right);

};

 

int BootsExchange::leastAmount(vector <int> left, vector <int> right)

{

        int cnt = 0;

       

        for(int i = 0; i < left.size() ; i++)

        {

               for(int j = 0; j < right.size() ; j++)

               {

                       if(left[i] == right[j])

                       {

                              right[j] = 0;

                              break;

                       }

                       else

                       {

                              if(j == right.size() - 1) cnt++;

                       }

               }

        }

        return cnt;

}

 

'Programming > SRM Practice' 카테고리의 다른 글

SRM 150 DIV 2 (250)  (0) 2009.09.15
SRM 149 DIV 2 (250)  (0) 2009.09.15
SRM 191 DIV 2 (250)  (0) 2009.05.30
SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
: