Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;
const double PI=3.14159265358979323846;

ll N,K;
cin>>N>>K;
vector<int> A;
vector<int> F;
REP(i,N){
  int a;
  cin>>a;
  A.push_back(a);
}
REP(i,N){
  int a;
  cin>>a;
  F.push_back(a);
}

SORT(A);
SORT(F);
REVERSE(F);




// index が条件を満たすかどうか
bool isOK(ll index) {
  for(int i=0; i<N; ++i){
    while(A.at(i)*F.at(i)>index && K>=0){
      A.at(i)--;
      K--;
      if(K==0) return false;
    }
  }
  return true;
}



int main(){
  ll ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
  ll ok = N; // 「index = N-1」が条件を満たさないこともあるので、初期値は N
  
  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
      ll mid = (ok + ng) / 2;
    
      if (isOK(mid)){
        ok = mid;
      }
    
      else ng = mid;
  }
  
  cout<<ok<<endl;
}

Compiler output:
a.cc:23:1: error: 'cin' does not name a type
   23 | cin>>N>>K;
      | ^~~
a.cc:11:20: error: expected unqualified-id before 'for'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                    ^~~
a.cc:13:19: note: in expansion of macro 'FOR'
   13 | #define REP(i,n)  FOR(i,0,n)
      |                   ^~~
a.cc:26:1: note: in expansion of macro 'REP'
   26 | REP(i,N){
      | ^~~
a.cc:26:5: error: 'i' does not name a type
   26 | REP(i,N){
      |     ^
a.cc:11:34: note: in definition of macro 'FOR'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                  ^
a.cc:26:1: note: in expansion of macro 'REP'
   26 | REP(i,N){
      | ^~~
a.cc:11:40: error: expected unqualified-id before '++' token
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                        ^~
a.cc:13:19: note: in expansion of macro 'FOR'
   13 | #define REP(i,n)  FOR(i,0,n)
      |                   ^~~
a.cc:26:1: note: in expansion of macro 'REP'
   26 | REP(i,N){
      | ^~~
a.cc:11:20: error: expected unqualified-id before 'for'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                    ^~~
a.cc:13:19: note: in expansion of macro 'FOR'
   13 | #define REP(i,n)  FOR(i,0,n)
      |                   ^~~
a.cc:31:1: note: in expansion of macro 'REP'
   31 | REP(i,N){
      | ^~~
a.cc:31:5: error: 'i' does not name a type
   31 | REP(i,N){
      |     ^
a.cc:11:34: note: in definition of macro 'FOR'
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                  ^
a.cc:31:1: note: in expansion of macro 'REP'
   31 | REP(i,N){
      | ^~~
a.cc:11:40: error: expected unqualified-id before '++' token
   11 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |                                        ^~
a.cc:13:19: note: in expansion of macro 'FOR'
   13 | #define REP(i,n)  FOR(i,0,n)
      |                   ^~~
a.cc:31:1: note: in expansion of macro 'REP'
   31 | REP(i,N){
      | ^~~
a.cc:15:21: error: expected constructor, destructor, or type conversion before '(' token
   15 | #define SORT(V) sort((V).begin(),(V).end())
      |                     ^
a.cc:37:1: note: in expansion of macro 'SORT'
   37 | SORT(A);
      | ^~~~
a.cc:15:21: error: expected constructor, destructor, or type conversion before '(' token
   15 | #define SORT(V) sort((V).begin(),(V).end())
      |                     ^
a.cc:38:1: note: in expansion of macro 'SORT'
   38 | SORT(F);
      | ^~~~
a.cc:16:27: error: expected constructor, destructor, or type conversion before '(' token
   16 | #define REVERSE(V) reverse((V).begin(),(V).end())
      |                           ^
a.cc:39:1: note: in expansion of macro 'REVERSE'
   39 | REVERSE(F);
      | ^~~~~~~