Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <stdio.h>
- using namespace std;
- string input;
- stringstream stream;
- string newString;
- vector <int> noseniNomera(0);
- vector <int> nalichniNomera(0);
- vector <int> resultV(0);
- int firstNumber, secondNumber = 0;
- long sstoi(const char *s) // custom stoi function
- {
- long i;
- i = 0;
- while(*s >= '0' && *s <= '9')
- {
- i = i * 10 + (*s - '0');
- s++;
- }
- return i;
- }
- int solve()
- {
- int counter = 0;
- // for(int i =0; i<noseniNomera.size();i++)
- // {
- int l =0;
- int sizeNalichniNomera= nalichniNomera.size();
- for(int j =0; j<nalichniNomera.size();j++)
- {
- if(l==sizeNalichniNomera)
- {
- break;
- }
- int currNosenNomer = noseniNomera[l];
- int currNalichenNomer = nalichniNomera[j];
- //if((noseniNomera[i]<=nalichniNomera[j]) && (nalichniNomera[j]!=0))
- if((currNosenNomer<=currNalichenNomer) && (currNalichenNomer!=0))
- {
- nalichniNomera[j]=0;
- l++;
- counter++;
- // break;
- }
- }
- return counter;
- }
- int main()
- {
- //ios_base::sync_with_stdio(false);
- int k =0;
- cin >> k;
- cin.ignore();
- int loopCounter = 0;
- while(k--)
- {
- getline(cin,input);
- stream.str(input);
- stream >> newString;
- firstNumber = sstoi(newString.c_str());
- stream >> newString;
- secondNumber = sstoi(newString.c_str());
- stream.clear();
- input = "";
- getline(cin, input);
- stream.str(input);
- int newNum =0;
- while(stream>>newNum)
- {
- // int currentNum = sstoi(newString.c_str());
- int currentNum = newNum;
- noseniNomera.push_back(currentNum);
- }
- // cin.ignore();
- getline(cin, input);
- stream.str(input);
- stream.clear();
- input = "";
- while(stream>>newString)
- {
- int currentNum = sstoi(newString.c_str());
- nalichniNomera.push_back(currentNum);
- }
- stream.clear();
- int result = solve();
- //resultV.push_back(result);
- // resultV[loopCounter] = result;
- loopCounter ++;
- //cout << "The result is: " <<result << endl;
- cout << result << endl;
- noseniNomera.clear();
- nalichniNomera.clear();
- input = "";
- // cout << "the first number is: " << firstNumber << " and the second number is: " << secondNumber << endl;
- }
- /* for(int i =0; i<resultV.size();i++)
- //for(int i =0; i<loopCounter; i++)
- {
- cout << resultV[i] << endl;
- // printf("%d \n", resultV[i]);
- }
- */
- /*
- for(int i =0; i<noseniNomera.size(); i++)
- {
- cout << "First string" << noseniNomera[i] << endl;
- }
- for(int i =0; i<noseniNomera.size(); i++)
- {
- cout << "Second string" << nalichniNomera[i]<< endl;
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement