답안 #498405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498405 2021-12-25T06:28:46 Z AQ0212 Sure Bet (CEOI17_sure) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cstring>

// #pragma GCC optimize("inline")
// #pragma GCC optimize("-fgcse,-fgcse-lm")
// #pragma GCC optimize("-ftree-pre,-ftree-vrp")
// #pragma GCC optimize("-ffast-math")
// #pragma GCC optimize("-fipa-sra")
// #pragma GCC optimize("-fpeephole2")
// #pragma GCC optimize("-fsched-spec")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#define ll long long int
#define pb push_back
#define pll pair < ll , ll >
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

ll inf2 = 3e18;

double a[ 100111 ], b[ 100111 ], sum1, sum2, sit1, sit2, cnt, grnt;
pair < double , double > c[ 100111 ];
vector < pll > unused, overused;

int main(){
    ll n;

    cin >> n;

    for(int i = 1; i <= n; i ++){
        cin >> a[ i ] >> b[ i ];

        // c[ i ].fi = a[ i ];
        // c[ i ].se = b[ i ];
    }

    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);

    sum1 += a[ n ];
    sum2 += b[ n ];
    cnt += 2.0;
    sit1 = sum1 - cnt;
    sit2 = sum2 - cnt;
    grnt = min(sit1, sit2);

    for(int i = n - 1; i >= 1; i --){
        if(a[ i ] + sum1 - cnt - 1.0 > grnt && sum2 - cnt - 1.0 > grnt){
            sum1 += a[ i ];
            cnt ++;
            sit1 = sum1 - cnt;
            sit2 = sum1 - cnt;
            grnt = min(sit1, sit2);
        }
        if(b[ i ] + sum2 - cnt - 1.0 > grnt && sum1 - cnt - 1.0 > grnt){
            sum2 += b[ i ];
            cnt ++;
            sit1 = sum1 - cnt;
            sit2 = sum2 - cnt;
            grnt = min(sit1, sit2);
        }
    }

    printf("%.4lf", max(0, grnt));
}

/*

4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5

*/

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:76:32: error: no matching function for call to 'max(int, double&)'
   76 |     printf("%.4lf", max(0, grnt));
      |                                ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from sure.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:
sure.cpp:76:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   76 |     printf("%.4lf", max(0, grnt));
      |                                ^
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from sure.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:
sure.cpp:76:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   76 |     printf("%.4lf", max(0, grnt));
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from sure.cpp:2:
/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:
sure.cpp:76:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   76 |     printf("%.4lf", max(0, grnt));
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from sure.cpp:2:
/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:
sure.cpp:76:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   76 |     printf("%.4lf", max(0, grnt));
      |                                ^