Submission #962183

# Submission time Handle Problem Language Result Execution time Memory
962183 2024-04-13T08:40:04 Z LCJLY Autobahn (COI21_autobahn) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;	
 
//#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<long long,int>pii;
typedef pair<int,pii>pi2;

inline long long combine(long long a, long long b){
	return a+b;
}

struct node{
	int s,e,m;
	node *l,*r;
	long long v;
	long long lazyUpd;
	
	node(int ss, int ee):s(ss),e(ee),m((s+e)>>1),l(NULL),r(NULL),v(0),lazyUpd(0){
	}
	
	inline void inst(){
		if(l==NULL) l=new node(s,m);
		if(r==NULL) r=new node(m+1,e);
	}
	
	void self_add(int x){
		v+=(e-s+1)*x;
		lazyUpd+=x;
	}
	
	void forceProp(){
		if(s==e) return;
		if(lazyUpd){
			l->self_add(lazyUpd),r->self_add(lazyUpd);
			lazyUpd=0;
		}
	}
	
	void rangeUpd(int x, int y, int c){
		if(x<=s&&y>=e){
			self_add(c);
			return;
		}
		inst();
		forceProp();
		if(x<=m) l->rangeUpd(x,y,c);
		if(y>m){
			r->rangeUpd(x,y,c);
		}
		v=combine(l->v,r->v);
	}	
	
	int query(int x, int y){
		if(x<=s&&y>=e){
			return v;
		}
		inst();
		forceProp();
		if(y<=m) return l->query(x,y);
		if(x>m) return r->query(x,y);
		return combine(l->query(x,m),r->query(m+1,y)); 
	}
};

struct event{
	int type, sign;
	event(int tt, int ss):type(tt),sign(ss){}
};

void solve(){
	int n,k,m;
	cin >> n >> k >> m;
	
	int temp,temp2,temp3;
	map<int,vector<event>>mp;
	for(int x=0;x<n;x++){
		cin >> temp >> temp2 >> temp3;
		event hold(0,1);
		event hold2(0,-1);
		mp[temp].push_back(hold);
		mp[temp+temp2].push_back(hold2);
		
		if(temp+temp2<=temp3){
			event hold3(1,1);
			event hold4(1,-1);
			mp[temp+temp2].push_back(hold3);
			mp[temp3+1].push_back(hold4);
		}
	}
	
	int last=0;
	int car=0;
	int unpaid=0;
	node st(0,1e9+5);
	vector<int>v;
	
	for(auto index:mp){
		//show(index.first,index.first);
		if(car>=k){
			st.rangeUpd(last,index.first-1,unpaid);
			v.push_back(index.first-1);
			v.push_back(last+m-1);
		}
		
		for(auto it:index.second){
			if(it.type==0){
				//paid
				car+=it.sign;
			}
			else{
				//unpaid
				car+=it.sign;
				unpaid+=it.sign;
			}
		}
		last=index.first;
	}
	
	long long best=0;
	for(auto it:v){
		int r=min(it,(int)1e9+5);
		int l=max(r-m+1,0LL);
		best=max(best,st.query(l,r));
	}
	cout << best;
}
 
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
}

Compilation message

autobahn.cpp: In function 'void solve()':
autobahn.cpp:127:22: error: no matching function for call to 'max(int, long long int)'
  127 |   int l=max(r-m+1,0LL);
      |                      ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
autobahn.cpp:127:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  127 |   int l=max(r-m+1,0LL);
      |                      ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
autobahn.cpp:127:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  127 |   int l=max(r-m+1,0LL);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
autobahn.cpp:127:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  127 |   int l=max(r-m+1,0LL);
      |                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
autobahn.cpp:127:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  127 |   int l=max(r-m+1,0LL);
      |                      ^
autobahn.cpp:128:30: error: no matching function for call to 'max(long long int&, int)'
  128 |   best=max(best,st.query(l,r));
      |                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
autobahn.cpp:128:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  128 |   best=max(best,st.query(l,r));
      |                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
autobahn.cpp:128:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  128 |   best=max(best,st.query(l,r));
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
autobahn.cpp:128:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  128 |   best=max(best,st.query(l,r));
      |                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from autobahn.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
autobahn.cpp:128:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  128 |   best=max(best,st.query(l,r));
      |                              ^