답안 #104128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104128 2019-04-04T07:35:52 Z Fasho Rasvjeta (COCI17_rasvjeta) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,m,ar[N],sum,k,tut[N],mark[N];


int main()
{
	fast;
	cin>>n>>m>>k;
	fs(ar,m);
	sort(ar+1,ar+1+m);

	for(int i=1;i<=m;i++)
		for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
			mark[j]=1;
	ll last=INT_MIN;
	// fo(i,1,n)
	// 	cout<<mark[i]<<sp;
	// 	cout<<endl;
	for(int i=1;i<=n;i++)
	{
		if(i-last>k*2 && !mark[i])
			last=i,sum++;
	}
	cout<<sum;
}

Compilation message

rasjveta.cpp: In function 'int main()':
rasjveta.cpp:31:26: error: no matching function for call to 'max(long long int, int)'
   for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rasjveta.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
rasjveta.cpp:31:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
                          ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from rasjveta.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
rasjveta.cpp:31:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from rasjveta.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
rasjveta.cpp:31:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
                          ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from rasjveta.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
rasjveta.cpp:31:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   for(int j=max(ar[i]-k,1);j<=ar[i]+k && j<=n;j++)
                          ^