답안 #674271

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674271 2022-12-23T15:35:11 Z Ahmed57 Sparklers (JOI17_sparklers) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
int n,k;int t;
int arr[100001];

bool check(double mid){
    int l = k-1 , r = k+1 , lin = k , rin = k;
    int te = t , tel = t , ter = t , suml = 0, sumr = 0;
    int minl = 1000000000;
    int minr = 1000000000;
    while(1){
        double mi = 0;
        bool ss = 0;
        while(l>=0){
            double dis = ((arr[l+1]-arr[l])+1)/2;
            double tim = (dis+(mid-1))/mid;
            if(tel<tim){
                break;
            }
            minl = min(minl,tel-tim);
            tel-=tim;tel+=t;
            suml+=t-tim;
            if(suml>0){
                ss = 1;
                lin = l;
                minr+=suml;
                te = tel;
                ter += suml;
                suml = 0;
                minl = 1000000000;
            }
            l--;
        }while(r<n){
            double dis = ((arr[r]-arr[r-1])+1)/2;
            double tim = (dis+(mid-1))/mid;
            if(ter<tim){
                break;
            }
            minr = min(minr,ter-tim);
            ter-=tim;
            ter+=t;
            sumr+=t-tim;
            if(sumr>0){
                ss = 1;
                rin = r;
                minl+=sumr;
                te = ter;
                tel += sumr;
                sumr = 0;
                minr = 1000000000.0;
            }
            r++;
        }
        if(lin==0&&rin==n-1)return 1;
        if(l==-1&&r==n&&((minr>=te-suml)||(minl>=te-sumr))){
            return 1;
        }
        if(ss==0)return 0;
    }
    return 1;
}
int main(){
    cin>>n>>k>>t;
    k--;
    for(int i = 0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    if(arr[0]==arr[n-1]){
        cout<<0<<"\n";
        return 0;
    }
    int l = 1 , r = 1e9 , ans = 0;
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid)){
            r = mid-1;
            ans = mid;
        }else l = mid+1;
    }
    cout<<ans;
}

Compilation message

sparklers.cpp: In function 'bool check(double)':
sparklers.cpp:21:36: error: no matching function for call to 'min(int&, double)'
   21 |             minl = min(minl,tel-tim);
      |                                    ^
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 sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
sparklers.cpp:21:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   21 |             minl = min(minl,tel-tim);
      |                                    ^
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 sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
sparklers.cpp:21:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   21 |             minl = min(minl,tel-tim);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
sparklers.cpp:21:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |             minl = min(minl,tel-tim);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
sparklers.cpp:21:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |             minl = min(minl,tel-tim);
      |                                    ^
sparklers.cpp:40:36: error: no matching function for call to 'min(int&, double)'
   40 |             minr = min(minr,ter-tim);
      |                                    ^
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 sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
sparklers.cpp:40:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   40 |             minr = min(minr,ter-tim);
      |                                    ^
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 sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
sparklers.cpp:40:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   40 |             minr = min(minr,ter-tim);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
sparklers.cpp:40:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |             minr = min(minr,ter-tim);
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sparklers.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
sparklers.cpp:40:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |             minr = min(minr,ter-tim);
      |                                    ^
sparklers.cpp:13:16: warning: unused variable 'mi' [-Wunused-variable]
   13 |         double mi = 0;
      |                ^~