QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#775902#9730. Elevator IIhaomiao000Compile Error//C++142.0kb2024-11-23 17:01:002024-11-23 17:01:00

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 17:01:00]
  • 评测
  • [2024-11-23 17:01:00]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 7;
struct Man {
    int st;
    int ed;
    int tag;
    bool operator < (const Man b) const {
        return ed < b.ed;
    }
    Man(int x , int y , int z) {
        st = x;
        ed = y;
        tag = z;
    }
};
bool cmp(Man x , Man y) {
    return x.st < y.st;
}
signed main() {
    int t;
    cin >> t;
    while(t --) {
        vector<Man> vec;
        int n , f;
        cin >> n >> f;
        for(int i = 0; i < n; i ++) {
            int l , r;
            cin >> l >> r;
            vec.push_back(Man(l , r , i + 1));
        }
        multiset<Man>st;
        sort(vec.begin() , vec.end() , cmp);
        int i = 0;
        int ans = 0;
        vector<int>tmp;
        auto now = Man(f , 0 , 0);
        while(i != n || !st.empty()) {
            if(i == n) {
                auto it = --st.end();
                ans += max(0 , it->st - now.st) + it->ed - it->st;
                now.st = it->ed;
                tmp.push_back(it->tag);
                st.erase(it);
            }else {
                if(vec[i].st <= now.st) {
                    st.insert(vec[i]);
                    i ++;
                    continue;
                }else {
                    if(st.empty()) {
                        st.insert(vec[i]);
                        i ++;
                    }
                    if((--st.end())->ed < now.st) {
                        st.insert(vec[i]);
                        i ++;
                        continue;
                    }
                    auto it = --st.end();
                    ans += max(0 , it->st - now.st) + it->ed - it->st;
                    now.st = it->ed;
                    tmp.push_back(it->tag);
                    st.erase(it);
                }
            }
        }
        cout << ans << endl;
        for(auto it : tmp) {
            cout << it << " ";
        }
        cout << endl;
        
    }
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:42:27: error: no matching function for call to ‘max(int, long long int)’
   42 |                 ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:42:27: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   42 |                 ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:42:27: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   42 |                 ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:42:27: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   42 |                 ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:42:27: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   42 |                 ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                        ~~~^~~~~~~~~~~~~~~~~~~~~
answer.code:62:31: error: no matching function for call to ‘max(int, long long int)’
   62 |                     ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
answer.code:62:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   62 |                     ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
answer.code:62:31: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘long long int’)
   62 |                     ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
answer.code:62:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   62 |                     ans += max(0 , it->st - now.st) + it->ed - it->st;
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
answer.code:62:31: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   62 |                     ans +=...