Submission details
Task:Apartments
Sender:aalto26bh_006
Submission time:2026-09-02 22:58:55 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:52:20: error: expected ';' before '}' token
   52 |                 l++
      |                    ^
      |                    ;
   53 |             }
      |             ~       
input/code.cpp:68:2: error: expected '}' at end of input
   68 | }
      |  ^
input/code.cpp:5:11: note: to match this '{'
    5 | int main(){
      |           ^

Code

#include <bits/stdc++.h> 
using namespace std;
#define REP(i,a,b) for (int i = a; i < b; i++)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    int m;
    int k;
    cin>>n>>m>>k;
    vector<int> desired(n);
    vector<int> size(m);
    REP(i,0,n){
        int a;
        cin>>a;
        desired[i]=a;
    }
    REP(i,0,m){
        int b;
        cin>>b;
        size[i]=b;
    }
    sort(desired.begin(),desired.end());
    sort(size.begin(),size.end());
    int count_desired=0;
    int count_size=0; 
    vector<pair<int,int>> liste;
    REP(i,0,m+n){
        if (count_size!=m && count_desired!=n){
        if (desired[count_desired]<size[count_size]){
            liste.push_back({desired[count_desired],0});
            count_desired++;
            
        }
        else {
            liste.push_back({size[count_size],1});
            count_size++;
        }
    }
    int compteur = 0;
    REP(i,0,m+n){
        if (liste[i].second==0){
            int l = 1;
            while((i+l<m+n)&&(max(liste[i].first-liste[i+l].first,liste[i+l].first-liste[i].first)<k)){
                if (liste[i+l].second==1){
                    liste[i+l].second=-1;
                    liste[i].second=-1;
                    compteur++;
                    continue;
                }
                l++
            }
        }
        if (liste[i].second==1){
            int l = 1;
            while((i+l<m+n)&&(max(liste[i].first-liste[i+l].first,liste[i+l].first-liste[i].first)<=k)){
                if (liste[i+l].second==0){
                    liste[i+l].second=-1;
                    liste[i].second=-1;
                    compteur++;
                }
            }
        }
    }
    cout<<compteur;
    return 0;
}