Monday, May 1, 2017

URI Solution 1245 Lost Boots - Solution in C++ | Ad Hoc

URI Solution 1245 Lost Boots - Solution in C++ | Ad Hoc


URI Online Judge Solution  Lost Boots | Ad Hoc

Problem Name: URI Problem Lost Boots
Problem Number : URI Problem 1245 Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus

URI Solution 1245 Code in CPP:


#include <iostream>
#include <vector>
using namespace std;

int main()
{
 int n, tam, counter, tmp;
 char c;

 while(cin >> n)
 {
  vector<int> vec_e(61);
  vector<int> vec_d(61);
  counter = 0;

  for (int i = 0; i < n; ++i)
  {
   cin >> tam >> c;

   if(c == 'D'){
    vec_d[tam]++;
   }else{
    vec_e[tam]++;
   }
  }

  for (int i = 30; i < 61; ++i)
  {
   if(vec_e[i] != 0 && vec_d[i]){
    if(vec_e[i] == vec_d[i]){
     counter += vec_e[i];
    }else{
     if(vec_e[i] < vec_d[i]){
      counter += vec_e[i]; 
     }else{
      counter += vec_d[i];
     }
    }
   }
  }

  cout << counter << endl;
 }

 return 0;
}

No comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.