Submission details
Task:Apartments
Sender:aalto26bh_019
Submission time:2026-09-04 19:45:00 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(a, a + n);
      |         ^~~~
      |         short

Code

#include <iostream>

using namespace std;

#define N (2 * (int)1e5)

bool accepts(int applicant, int apartment, int k){
	if(applicant - k <= apartment && applicant + k >= apartment)
		return true;
	return false;
	}

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	int a[n], b[m];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int j = 0; j < n; j++){
		cin >> b[j];
	}
	
	sort(a, a + n);
	sort(b, b + m);
	
	int la = 0, lb = 0, ra = n - 1, rb = m - 1;
	int result = 0;
	while (lb < rb && lb <= la){
		if(accepts(lb, la, k)){
			lb++;
			result++;
		}
		else la++;
		if(accepts(rb, ra, k)){
			rb--;
			result++;
		}
		else rb--;
	}
	cout << result << endl;
	
	return 0;
}