답안 #1076983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076983 2024-08-26T20:13:32 Z bleahbleah Tortoise (CEOI21_tortoise) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
#define _ << " " <<
 
const int MAXN = 5e5 + 5;
const int off = 1 << 19;
const int inf = 1e9;
 
 #define int long long
 
int a[MAXN];
int l[MAXN];
int r[MAXN];
int before[MAXN];
 
unordered_map<int, int> specialChair;
 
typedef pair<int, int> pii;
  
bool possible(multiset<int> s)
{
    int last = -1, timer = 0;
    for(auto x : s)
    {
        if(last == -1) {
            timer += x;
        }
        else {
            if (r[last] <= l[x])
                timer += x - last;
            else 
               timer += min(last - l[last] + x - l[last], r[last] - last + r[last] - x);
        }
        if(timer > 2 * (x)) {
            return 0;
        }
        last = x;
    }
    return 1;
}

long long sum;
 
multiset<int> TT;
 
void solve(int x, int d, int type) {
    int cnt = 0;
    while(a[x] > 0) {
         TT.insert(x);
         if(possible(TT)) {
           a[x] --;
           sum --;
           cnt ++;
         }
         else {
            TT.erase(TT.find(x));
            break;
         }
    }
}
int v[MAXN];
 
signed main() {
    int n; cin >> n;
 
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        v[i] = a[i];
        if (a[i] != -1) sum += a[i];
    }
 
    int tmp = -inf;
    for (int i = 0; i < n; ++i) {
        if (a[i] == -1) {
            tmp = i;
        }
        l[i] = tmp;
    }
    tmp = inf;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == -1) {
            tmp = i;
        }
        r[i] = tmp;
    }
 
 
    
    vector<pair<int, pii>> candidates;
    for (int i = 0; i < n; ++i) {
        if (a[i] > 0) {
            if (r[i] != inf) {
                candidates.push_back({r[i] - i, {i, 1}});
            }
            if (l[i] != -inf) {
                candidates.push_back({i - l[i], {i, 0}});
            }
        }
    }
    sort(candidates.begin(), candidates.end());
   
   for(int i = 0; i < n; i++) {
      if(a[i] == -1) continue;
      int p = i;
      for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      if(a[p] == 0) { i = r[i]; continue; }
      a[p]--;
      TT.emplace(p);
      i = r[i];
   }
   
 
    for (auto candidate : candidates) {
        int x = candidate.second.first;
        int d = candidate.first;
        int type = candidate.second.second;
 
        solve(x, d, type);
    }
 
   sum =0;
   for(int i = 0; i < n; i++) sum += max(a[i], 0ll);
   
    cerr << '\n';
    cout << sum << '\n';
 
}

Compilation message

tortoise.cpp: In function 'int main()':
tortoise.cpp:106:95: error: no matching function for call to 'min(const int&, long long int)'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tortoise.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:
tortoise.cpp:106:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                               ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tortoise.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:
tortoise.cpp:106:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tortoise.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:
tortoise.cpp:106:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tortoise.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:
tortoise.cpp:106:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                               ^
tortoise.cpp:106:117: error: no matching function for call to 'min(const int&, long long int)'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tortoise.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:
tortoise.cpp:106:117: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                                                     ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from tortoise.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:
tortoise.cpp:106:117: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tortoise.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:
tortoise.cpp:106:117: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from tortoise.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:
tortoise.cpp:106:117: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  106 |       for(int j = i + 1; j < min(n, r[i]); j++) if(a[j] > 0 && (a[p] == 0 || min(inf, j - l[j])) < min(inf, p - l[p])) { p = j; }
      |                                                                                                                     ^