Submission details
Task:Sprinklers
Sender:a256
Submission time:2025-03-03 17:00:37 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int kolme()':
input/code.cpp:41:22: error: no matching function for call to 'max(int&, long long int&)'
   41 |                 r=max(r,et);
      |                   ~~~^~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from input/code.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
input/code.cpp:41:22: note:   deduced conflicti...

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100000
void onesp();

int n,m,s[N],S[N],f[N],r,cnf;

int toimii(int k){
	for(int M=0;M<(1<<n);++M){
		int tm=1;
		for(int i=0;i<m;++i){
			int mn=INT_MAX;
			for(int j=0;j<n;++j){
				if(!(M&(1<<j))&&f[i]<=s[j]) mn=min(mn,s[j]-f[i]);
				if((M&(1<<j))&&s[j]<=f[i]) mn=min(mn,f[i]-s[j]);
			}
			if(mn>k){
				tm=0;
				break;
			}
		}
		if(tm){
			cnf=M;
			return 1;
		}
	}
	return 0;
}

int kolme(){
	n/=3;
	r=0;
	int L=0,R=0;
	for(int i=0;i<m;++i){
		while(R<n&&S[R]<=f[i]) ++R;
		while(L<n-1&&S[L+1]<=f[i]) ++L;
		ll et=1e12;
		if(R<n) et=abs((ll)f[i]-S[R]);
		et=min(et,abs((ll)S[L]-f[i]));
		r=max(r,et);
	}

	cout<<r<<'\n';
	for(int i=0;i<n;++i) cout<<"LRL";
	cout<<'\n';
	exit(0);
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin>>n>>m;
	for(int i=0;i<n;++i) cin>>s[i];
	for(int i=0;i<m;++i) cin>>f[i];
	if(n==1) onesp();
	if(!(n%3)){
		int nn=n/3;
		int tm=1;
		for(int i=0;i<nn;++i){
			int a=s[3*i],b=s[3*i+1],c=s[3*i+2];
			if(a!=b||b!=c||a!=c){
				tm=0;
				break;
			}
			S[i]=a;
		}
		if(tm) kolme();
	}
	r=0;
	for(int k=1<<30;k;k/=2){
		if(!toimii(r+k)) r+=k;
	}
	if(r==0&&toimii(0)){
		cout<<"0\n";
	} else {
		cout<<r+1<<'\n';
		assert(toimii(r+1)); // !!!!tarvitaan!!!!
	}
	for(int i=0;i<n;++i){
		if(cnf&(1<<i)) cout<<"R";
		else cout<<"L";
	}
	cout<<'\n';
}

void onesp(){
		int r=0;
		int lc=0,rc=0;
		for(int i=0;i<m;++i){
			if(f[i]<s[0]) ++lc;
			if(f[i]>s[0]) ++rc;
			r=max(abs(f[i]-s[0]),r);
		}
		if(lc&&rc){
			cout<<"-1\n";
			exit(0);
		}
		cout<<r<<'\n';
		if(lc) cout<<"L\n";
		if(rc) cout<<"R\n";
		exit(0);
}