제출 #1155512

#제출 시각아이디문제언어결과실행 시간메모리
1155512eyadoozGlobal Warming (CEOI18_glo)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <math.h>
#include <array>
#include <random>
#include <bitset>
#include <climits>
#include <cstring>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define mod 1000000007
#define INF 0x3f3f3f3f

#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,sse3,sse4,avx")
#pragma GCC target("popcnt")

template <class x>
using ordered_set = tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ipair;

static inline int read()
{
    int x = 0;char ch = getchar();
    while (ch < '0' || ch>'9') ch = getchar();
    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x;
}

static inline void print(const int &x) {
    if (x > 9)print(x / 10);
    putchar('0' + x % 10);
}

int main()
{
    cin.tie(0) -> sync_with_stdio(0);

    int n, x;

    cin >> n >> x;

    int list[n];
    for(int i = 0;i < n;cin >> list[i++]);

    int mx = 0;
    for(int q = 0;q < n;q++)
    {
        for(int j = 1;j <= x;j++)
        {
            list[q] += j;
            vector<int> taken;
            taken.push_back(list[0]);
            for(int i = 1;i < n;i++)
            {
                if(taken.back() >= list[i])
                {
                    auto it = lower_bound(taken.begin(), taken.end(), list[i]) - taken.begin();

                    taken[it] = list[i];
                }
                else
                {
                    taken.push_back(list[i]);
                }
            }

            mx = max(taken.size(), mx);
            list[q] -= j;
        }
    }

    cout << mx;
}

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int main()':
glo.cpp:83:21: error: no matching function for call to 'max(std::vector<int>::size_type, int&)'
   83 |             mx = max(taken.size(), mx);
      |                  ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from glo.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
glo.cpp:83:21: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   83 |             mx = max(taken.size(), mx);
      |                  ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from glo.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
glo.cpp:83:21: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   83 |             mx = max(taken.size(), mx);
      |                  ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from glo.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
glo.cpp:83:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   83 |             mx = max(taken.size(), mx);
      |                  ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from glo.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
glo.cpp:83:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   83 |             mx = max(taken.size(), mx);
      |                  ~~~^~~~~~~~~~~~~~~~~~