Submission #1195430

#TimeUsernameProblemLanguageResultExecution timeMemory
1195430JuanJLSelf Study (JOI22_ho_t2)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

#define fst first 
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i < b; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n';
#define pi pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;

int main(){
	ll n,m; cin>>n>>m;
	vector<ll> a(n); forn(i,0,n) cin>>a[i];
	vector<ll> b(n); forn(i,0,n) cin>>b[i];
	
	forn(i,0,n) a[i]=max(a[i],b[i]);
	
	ll l = 1; ll r = 9000000000000000000+5;
	while(l<=r){
		ll mid=(l+r)/2;
		
		//cout<<mid<<'\n';
		
		ll libres = 0;
		ll necesarias = 0;
		vector<ll> falta(n,mid);
		forn(i,0,n){
			
			if(m*a[i]<mid){	
				necesarias[i]=(mid-(m*a[i]))/b[i];
				if((mid-(m*a[i]))%b[i]!=0) necesarias[i]++;
				
			}else{
				ll nl = mid/a[i];
				if(mid%a[i]!=0) nl++;
				libres+=m-nl;
			}
		}
		
		if(libres>=necesarias) l=mid+1;
		else r=mid-1;
	}
	cout<<r<<'\n';
	return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:41:43: error: invalid types 'll {aka long long int}[int]' for array subscript
   41 |                                 necesarias[i]=(mid-(m*a[i]))/b[i];
      |                                           ^
Main.cpp:42:70: error: invalid types 'll {aka long long int}[int]' for array subscript
   42 |                                 if((mid-(m*a[i]))%b[i]!=0) necesarias[i]++;
      |                                                                      ^