답안 #166750

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166750 2019-12-03T16:28:02 Z theStaticMind Krov (COCI17_krov) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000000007
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
struct Line{
      int M,N;
      int X,Y;
      Line(int a,int b,int c,int d){
            M=a;N=b;X=c;Y=d;
      }
      int get(){
            if(M<0){
                 return M*Y+N;
            }
            else return M*X+N;
      }
};
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,ans=INF;
      cin>>n;
      vector<int>arr(n);
      vector<int>need(n);
      for(int i=0;i<n;i++)cin>>arr[i];
      for(int i=0;i<n;i++)arr[i]--;
      for(int i=0;i<n;i++){
            need[i]=i;
      }
      for(int i=n-1;i>=0;i--){
            map<int,int>critic;
            int mn=max((int)0,-(i-(n-i-1))),sum=0;
            for(int j=0;j<n;j++){
                  critic[arr[j]-need[j]]++;
                  sum-=need[j]-arr[j];
            }
            int m=-n;
            vector<Line> data;
            map<int,int>::iterator pre=critic.begin(),curr;
            curr=pre;
            curr++;
            if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
            m+=2*pre->second;
            sum-=2*pre->second*pre->first;
            while(curr!=critic.end()){
                  if(curr->first>=mn)data.pb(Line(m,sum,max(mn,pre->first),curr->first));
                  m+=2*curr->second;
                  sum-=2*curr->second*curr->first;
                  pre++;
                  curr++;
            }
            data.pb(Line(m,sum,max(mn,pre->first),INF));
            int cnt=INF;
            for(int j=0;j<data.size();j++){
                  cnt=min(cnt,data[j].get());
            }
            ans=min(ans,cnt);
            for(int j=n-1;j>=i;j--){
                  need[j]-=2;
            }
      }
      cout<<ans;
}

Compilation message

krov.cpp: In function 'int32_t main()':
krov.cpp:50:61: error: no matching function for call to 'max(long long int&, long int)'
             if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
                                                             ^
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 krov.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:
krov.cpp:50:61: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
             if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
                                                             ^
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 krov.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:
krov.cpp:50:61: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
             if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
                                                             ^
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 krov.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:
krov.cpp:50:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
                                                             ^
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 krov.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:
krov.cpp:50:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
             if(pre->first>=mn)data.pb(Line(m,sum,max(mn,-INF),pre->first));
                                                             ^
krov.cpp:62:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0;j<data.size();j++){
                         ~^~~~~~~~~~~~