Hello,
For CSES Problem Apartments: CSES - Apartments,
for the larger test cases, it gives me a time limit error
In Usaco bronze, there are also large cases, so how do I determine how much time those large test cases will take in the USACO server, and if it will pass in the 2 second time limit.
Please let me know. Thanks!
this is my code:
// https://cses.fi/problemset/task/1084
#include <bits/stdc++.h>
using namespace std;
int main()
{
// n - the number of applicants
// m - the number of apartments
// k - maximum allowed difference
int num_app, num_apt, diff;
int ans = 0;
cin >> num_apt >> num_app >> diff;
// a - the desired apartment size of each applicant
// b - the size of each apartment
vector<int> applicants (num_app);
vector<int> apt_size (num_apt);
for (int j = 0; j < num_apt; j++)
{
cin >> apt_size[j];
}
for (int i = 0; i < num_app; i++)
{
cin >> applicants[i];
}
for (int i = 0; i < num_app; i++)
{
for (int j = 0; j < num_apt; j++)
{
if (abs(applicants[i] - apt_size[j]) <= diff)
{
remove(v.begin(),v.end(),apt_size[j]);
ans++;
break;
}
}
}
cout << ans << endl;
}